I want to add a value to the onchange event, but the JS code has errors
$(args).attr('onChange', 'setTimeout('__doPostBack(\'ctl00$cpBody$txtDate\',\'\')', 0)');
anyone see error?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
How about the proper jQuery/ best Javascript way:
Although why the 0ms timeout period?
You can change your code to:
With only the most minor functional difference (
__doPostBackwill be executed immediately instead of ASAP).It’s better to provide a function as the first argument of setTimeout, as opposed to a string.
setTimeoutis closely related toeval, andevalis bad.