I'm trying to pass a variable with name "myPassword" in function jquery but variable value in function return null.how to correct this?!
我试图在函数jquery中传递一个名为“myPassword”的变量,但函数中的变量值返回null.how来纠正这个?!
$(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'
});
});
1 个解决方案
#1
Isn't it just the selector thats wrong (i.e. prepend with "."+ or "#" before)?
是不是只是选择器错了(即前面加上“。”+或“#”)?
var myPassword = $('#facebox #myPassword:first').val();
$("." + myPassword).strength({ ...
#1
Isn't it just the selector thats wrong (i.e. prepend with "."+ or "#" before)?
是不是只是选择器错了(即前面加上“。”+或“#”)?
var myPassword = $('#facebox #myPassword:first').val();
$("." + myPassword).strength({ ...