jQuery Attribute Starts With Selector
February 26, 2013
jQuery starts with selector works in the way that all the elements which starts with given selector are chosen for a given DOM element in the stack. The properties like val or css etc can be changed.
<script>$('p[id^="ab"]').css('background-color','green');</script>
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> </head> <body> <p id="abcd">ABCD</p> <p id="cdab">EFGH</p> <script>$('p[id^="ab"]').css('background-color','green');</script> </body> </html>
Output
ABCD
EFGH