I cannot get this to work. I simply want to display an alert for test purposes if the proposed td contains "OH".
<table id="v65-cart-shipping-details">
<tr>..</tr>
<tr>..</tr>
<tr>
<td>United States, OH 43112</td>
<tr>
</table>
No matter what is in it (ie. United States, MI 48187) the alert still pops up, what am I missing?
$(document).ready(function() {
if ($("#v65-cart-shipping-details tr:eq(2) td:contains('OH')")) {
alert("Did Stuff") }
});
Because it will return true even if the element isn't found. Try this:
$(document).ready(function() {
if ($("#v65-cart-shipping-details tr:eq(2) td:contains('OH')").length) {
alert("Did Stuff") }
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With