Javascript 多个文本框上的jQuery keyup赢得';我不能和IE11一起工作
我有多个文本框,并在每个文本框上调用jquery键 在mozilla firefox和chrome上很好。在internet explorer中 它的第一个文本框的工作很好,它的工作,因为它应该是完美的,但其他文本框工作不正常,我的意思是对他们来说,键盘没有调用。 .以下是我的代码:-Javascript 多个文本框上的jQuery keyup赢得';我不能和IE11一起工作,javascript,jquery,keyup,Javascript,Jquery,Keyup,我有多个文本框,并在每个文本框上调用jquery键 在mozilla firefox和chrome上很好。在internet explorer中 它的第一个文本框的工作很好,它的工作,因为它应该是完美的,但其他文本框工作不正常,我的意思是对他们来说,键盘没有调用。 .以下是我的代码:- <script type="text/javascript"> $(function(){ $(".search").keyup(function() {
<script type="text/javascript">
$(function(){
$(".search").keyup(function()
{
var searchid = $(this).val();
var idloc=document.getElementById("state").value;
var type='p_school';
var dataString = 'locality='+ searchid+'&id='+ idloc+'&type='+ type;
if(searchid!='')
{
$.ajax({
type: "POST",
url: "loaddata.php",
data: dataString,
cache: false,
success: function(html)
{
$("#result").html(html).show();
}
});
}return false;
});
jQuery("#result").on("click", ".show", function() {
var $name = $(this).find(".name").text();
var $id = $(this).find(".pid").text();
var type='state';
var pid='pid='+$id+'&type='+ type;
$.ajax({
type: "POST",
url: "load_state.php",
data: pid,
cache: false,
success: function(html)
{
//alert (html);
$('#p_school').show();
$('#p_school').html(html);
$('#p_school_old').hide();
}
});
$("#searchid").val($name);
});
jQuery(document).on("click", function(e) {
var $clicked = $(e.target);
if (! $clicked.hasClass("search")){
jQuery("#result").fadeOut();
}
});
if(searchid=='')
{
$('#searchid').click(function(){
jQuery("#result").fadeIn();
}); }
});
$(function(){
$(".search1").keyup(function()
{
alert ("hello second textbox");
var searchid1 = $(this).val();
var idloc1=document.getElementById("state1").value;
var type1='s_school';
var dataString1 = 'locality1='+ searchid1+'&id1='+ idloc1+'&type1='+ type1;
if(searchid1!='')
{
$.ajax({
type: "POST",
url: "loaddata.php",
data: dataString1,
cache: false,
success: function(html)
{
$("#result1").html(html).show();
}
});
}return false;
});
jQuery("#result1").on("click", ".show1", function() {
var $name = $(this).find(".name1").text();
var $id = $(this).find(".sid").text();
//var pid='pid='+ $id.+'&type='+ type;
var type='s_state';
var pid='pid='+$id+'&type='+ type;
$.ajax({
type: "POST",
url: "load_state.php",
data: pid,
cache: false,
success: function(html)
{
//alert (html);
$('#s_school').show();
$('#s_school').html(html);
$('#s_school_old').hide();
}
});
$("#searchid1").val($name);
//alert ("Danstring");
});
jQuery(document).on("click", function(e) {
var $clicked = $(e.target);
if (! $clicked.hasClass("search_ss")){
jQuery("#result1").fadeOut();
}
});
if(searchid1=='')
{
$('#searchid1').click(function(){
jQuery("#result1").fadeIn();
}); }
});
</script>
//HTML Code
HTML are below:-
<input type="text" placeholder="Primary School" name="primary[]" autocomplete="off" class="search" id="searchid" style="margin-top: 7px; border: 1px solid #7B9E94; min-height: 29px;">
<input type="text" placeholder="Secondary School" name="secondary[]" autocomplete="off" class="search1" id="searchid1" style="margin-top: 7px; border: 1px solid #7B9E94; min-height: 29px;">
Thanks
我有多个文本框,并在每个文本框上调用jquery键
在mozilla firefox和chrome上很好。在internet explorer中
它的第一个文本框的工作很好,它的工作,因为它应该是完美的,但其他文本框工作不正常,我的意思是对他们来说,键盘没有调用。
.以下是我的代码:-
<script type="text/javascript">
$(function(){
$(".search").keyup(function()
{
var searchid = $(this).val();
var idloc=document.getElementById("state").value;
var type='p_school';
var dataString = 'locality='+ searchid+'&id='+ idloc+'&type='+ type;
if(searchid!='')
{
$.ajax({
type: "POST",
url: "loaddata.php",
data: dataString,
cache: false,
success: function(html)
{
$("#result").html(html).show();
}
});
}return false;
});
jQuery("#result").on("click", ".show", function() {
var $name = $(this).find(".name").text();
var $id = $(this).find(".pid").text();
var type='state';
var pid='pid='+$id+'&type='+ type;
$.ajax({
type: "POST",
url: "load_state.php",
data: pid,
cache: false,
success: function(html)
{
//alert (html);
$('#p_school').show();
$('#p_school').html(html);
$('#p_school_old').hide();
}
});
$("#searchid").val($name);
});
jQuery(document).on("click", function(e) {
var $clicked = $(e.target);
if (! $clicked.hasClass("search")){
jQuery("#result").fadeOut();
}
});
if(searchid=='')
{
$('#searchid').click(function(){
jQuery("#result").fadeIn();
}); }
});
$(function(){
$(".search1").keyup(function()
{
alert ("hello second textbox");
var searchid1 = $(this).val();
var idloc1=document.getElementById("state1").value;
var type1='s_school';
var dataString1 = 'locality1='+ searchid1+'&id1='+ idloc1+'&type1='+ type1;
if(searchid1!='')
{
$.ajax({
type: "POST",
url: "loaddata.php",
data: dataString1,
cache: false,
success: function(html)
{
$("#result1").html(html).show();
}
});
}return false;
});
jQuery("#result1").on("click", ".show1", function() {
var $name = $(this).find(".name1").text();
var $id = $(this).find(".sid").text();
//var pid='pid='+ $id.+'&type='+ type;
var type='s_state';
var pid='pid='+$id+'&type='+ type;
$.ajax({
type: "POST",
url: "load_state.php",
data: pid,
cache: false,
success: function(html)
{
//alert (html);
$('#s_school').show();
$('#s_school').html(html);
$('#s_school_old').hide();
}
});
$("#searchid1").val($name);
//alert ("Danstring");
});
jQuery(document).on("click", function(e) {
var $clicked = $(e.target);
if (! $clicked.hasClass("search_ss")){
jQuery("#result1").fadeOut();
}
});
if(searchid1=='')
{
$('#searchid1').click(function(){
jQuery("#result1").fadeIn();
}); }
});
</script>
//HTML Code
HTML are below:-
<input type="text" placeholder="Primary School" name="primary[]" autocomplete="off" class="search" id="searchid" style="margin-top: 7px; border: 1px solid #7B9E94; min-height: 29px;">
<input type="text" placeholder="Secondary School" name="secondary[]" autocomplete="off" class="search1" id="searchid1" style="margin-top: 7px; border: 1px solid #7B9E94; min-height: 29px;">
Thanks
$(函数(){
$(“.search”).keyup(函数()
{
var searchid=$(this.val();
var idloc=document.getElementById(“state”).value;
var type='p_学校';
var dataString='locality='+searchid+'&id='+idloc+'&type='+type;
如果(搜索ID!='')
{
$.ajax({
类型:“POST”,
url:“loaddata.php”,
数据:dataString,
cache:false,
成功:函数(html)
{
$(“#结果”).html(html).show();
}
});
}返回false;
});
jQuery(#result”).on(“单击”,“显示”,函数()){
var$name=$(this.find(“.name”).text();
var$id=$(this.find(“.pid”).text();
var type='state';
var pid='pid='+$id+'&type='+type;
$.ajax({
类型:“POST”,
url:“load_state.php”,
数据:pid,
cache:false,
成功:函数(html)
{
//警报(html);
$('p#u school')。show();
$('p#u school').html(html);
$('p#u school_old').hide();
}
});
$(“#searchid”).val($name);
});
jQuery(document).on(“click”,函数(e){
var$clicked=$(e.target);
如果(!$clicked.hasClass(“搜索”)){
jQuery(“#result”).fadeOut();
}
});
如果(searchid='')
{
$('#searchid')。单击(函数(){
jQuery(“#result”).fadeIn();
}); }
});
$(函数(){
$(“.search1”).keyup(函数()
{
警报(“你好,第二个文本框”);
var searchid1=$(this.val();
var idloc1=document.getElementById(“state1”).value;
var type1='s_school';
var dataString1='locality1='+searchid1+'&id1='+idloc1+'&type1='+type1;
如果(searchid1!='')
{
$.ajax({
类型:“POST”,
url:“loaddata.php”,
数据:dataString1,
cache:false,
成功:函数(html)
{
$(“#result1”).html(html).show();
}
});
}返回false;
});
jQuery(“#result1”)。在(“单击“,”.show1”,函数(){
var$name=$(this.find(“.name1”).text();
var$id=$(this.find(“.sid”).text();
//变量pid='pid='+$id.+'&type='+type;
var type='s_state';
var pid='pid='+$id+'&type='+type;
$.ajax({
类型:“POST”,
url:“load_state.php”,
数据:pid,
cache:false,
成功:函数(html)
{
//警报(html);
$('s#u school')。show();
$('s#u school').html(html);
$('s#u school_old').hide();
}
});
$(“#searchid1”).val($name);
//警报(“Danstring”);
});
jQuery(document).on(“click”,函数(e){
var$clicked=$(e.target);
如果(!$clicked.hasClass(“搜索”)){
jQuery(“#result1”).fadeOut();
}
});
如果(searchid1=='')
{
$('#searchid1')。单击(函数(){
jQuery(“#result1”).fadeIn();
}); }
});
//HTML代码
HTML格式如下:-
谢谢
由于输入元素具有不同的类名,请尝试更改此行:
$(".search").keyup(function()
为此:
$(".search, .search_ss").keyup(function()
第二个元素的类名“search”不同,但“search”不同。我无法理解它是如何在Chrome或Mozilla上运行的。