简体   繁体   中英

jquery is not working with this id #tel / fax

I'm using this id(tel / fax) in this line

$("#" + val.target.id).attr('disabled', 'disabled');

then I get an error like:

Syntax error, unrecognized expression: #tel / fax

You cannot have spaces in id attribute. you can replace the space with any other character with replace() function.

ID should be one word without spaces and special chars. jQuery selecting works same as css selecting. For example, if you cannot write in your css #tel / fax {...} then you cannot do same in your jQuery - $('#tel / fax'); would throw you an error.

Just change your ID of element and it will work.

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