Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this jQuery code with square brackets and a caret mean?

Tags:

jquery

What does this jQuery code mean?

$('tr[id^="message"]')
like image 771
tgxiii Avatar asked Jun 26 '12 21:06

tgxiii


2 Answers

It means - select all tr elements which id attribute starts with message string

http://api.jquery.com/attribute-starts-with-selector/

like image 174
zerkms Avatar answered Sep 27 '22 21:09

zerkms


[] refers to an element's attribute(s) (id being one) and id^ is a wildcard which means the id must start with "message".

like image 41
riku Avatar answered Sep 27 '22 20:09

riku