- Forums
- Javascipt
- How To Use Wild Card Selector In Jquery Using A Div
this will show you how to use wildcards for selectors in jquery [8716], Last Updated: Sat May 18, 2024
jquery_audit
Wed Dec 31, 1969
0 Comments
135 Visits
im wriging this here to show you how you can match all divs matching a wild card
for example, lets say i want to show an alert on all Divs that end or start with MyDiv value, here is how i would do it:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Wild Card Jquery by wallpaperama.com</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script>
$(function (){
$('[id*="WildCard"]').click(function () {
alert('You Clicked '+ $(this).attr('id') );
});
});
</script>
</head>
<body>
<div id="WildCard1" >Click to see WildCard1</div>
<div id="WildCard2" >Click to see WildCard2</div>
</body>
</html>