我有三个html页面
home_frame.html
<html>
<head>
<script src="<?php echo base_url(); ?>js/jquery.js"></script>
<script src="<?php echo base_url(); ?>js/myscript.js"></script>
</head>
<body>
<div class="tab">
<button id="button1" >Button 1</button>
<button id="button2" >Button 2</button>
</div>
<div id="bt_one_content" >
</div>
<div id="bt_two_content" >
</div>
</body>
<html>
first.html
<html>
<head></head>
<body>
<input type="text" id="text1" >
<input type="button" id="bt_One" value="Say hello Button One">
</body>
</html>
second.html
<html>
<head></head>
<body>
<input type="text" id="text2" >
<input type="button" id="bt_two" value="Say hello Button Two">
</body>
</html>
当使用jquery和codeigniter点击相应的按钮时,我将first.html
和second.html
放在home_frame.html
myscript.js
$(document).ready(function(event){
$("#button1").click(function(event){
loadFirstView();
});
$("#button2").click(function(event){
loadSecondView();
});
$(document).on('click', '#bt_One', function(){
var val = $("#text1").val();
});
$(document).on('click', '#bt_two', function(){
var val = $("#text2").val();
});
});
Uncaught TypeError: "#text1".val is not a function