简体   繁体   中英

Can't read attribute value loaded by jQuery with i.e

How do you make ie read the value of attribute included to an element by query? Everything works fine with Safari, Chrome, Firefox. The value of "type" below returns undefined only with ie

$(document).ready(function() {
//edit post
$(function() 
{
    $("input[value='Edit']").click(function() 
    {
        $("input#password").attr("rel", "edit");
    });
return false;
});
//----end

//delete post
$(function() 
{
    $("input[value='Delete']").click(function() 
    {
        $("input#password").attr("rel", "delete");
    });
return false;
});
//----end
});


$( document ).on( "keypress", ".enter-pw", function(e){
var code = e.keyCode || e.which;
    if(code == 13) { 
        var password = $("input#password").val();
        var type = $(this).attr("rel");
        if(password == ""){
            return false
        }
        if(type=="delete"){
        //do stuffs
        }
        if(type=="edit"){
        //do stuffs
        }
return false;
}

});

Problem solved guys. It was caused by the placeholder plugin which activated only with ie .

Why do you use $(this) to get entry_id and $("input#password") to get password ? Can you try to use $("input#password") both time ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM