简体   繁体   中英

how to pass a variable in jquery

I'm trying to pass a variable with name "myPassword" in function jquery but variable value in function return null.how to correct this?!

$(document).ready(function ($) {
    var myPassword = $('#facebox #myPassword:first').val();
    $(myPassword).strength({
        strengthClass: 'strength',
        strengthMeterClass: 'strength_meter',
        strengthButtonClass: 'button_strength',
        strengthButtonText: 'Show Password',
        strengthButtonTextToggle: 'Hide Password'
    });
});

Isn't it just the selector thats wrong (ie prepend with "."+ or "#" before)?

 var myPassword = $('#facebox #myPassword:first').val();
 $("." + myPassword).strength({ ... 

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