$(function(){
$("#b1").click(function(){
alert($("#b1").value);
alert(document.getElementById("b1").value);
$.ajax({
url:"ajax.do",
type:"post",
dataType:"text",
data:"name=ReMind",
success:function(responseText){
alert(responseText);
},
error:function(){
alert("error");
}
});
});
});
今天使用jQuery出了一个很奇怪的问题,我能用$符绑定事件,编写方法,甚至能使用ajax方法,这说明我的jQuery导入是正确的,但是选择器无法使用。
可以看到我在前面写了两个alert,第一个输出的是null,第二个是正确的value。这是为什么。。。
------解决思路----------------------
$("#b1").val()