Reputation: 4759
I have an element that has two classes but can't seem to select it with jQuery. Is it possible. Here's the code:
<html>
<head runat="server">
<script type="text/javascript" src="abc/scripts/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
alert($(".x.y").html()); //shows null, I want it to show "456"
});
</script>
</head>
<body>
<div class="x" class"y">456</div>
</body>
</html>
Upvotes: 1
Views: 10084
Reputation: 35409
You should be able to target dual classes like so:
$(document).ready(function() {
alert($(".x.y").html()); //shows null, I want it to show "456"
});
with html like this:
<div class="x y">456</div>
Upvotes: 8
Reputation: 16533
This
<div class="x" class"y">456</div>
is incorrect, change it to
<div class="x y">456</div>
Upvotes: 4
Reputation: 10435
Having two class
attributes isn't valid SGML (therefore HTML), as far as I'm aware. Try this:
<div class="x y">456</div>
Upvotes: 8