views:

29

answers:

4

I'm trying to hide a layer but can't seem to figure out how to get this working here's what i'm trying

if ($('#dgAvailable_ctl02_lblpricefrom > strong').text() == '£'){
    $('#dgAvailable_ctl02_lblpricefrom').parent().parent().hide()
}

And my code is

<div class="resultsitem" style="background-color: rgb(238, 229, 208);">

<div class="petspeoplecontainer">
<h5><span class="lblpricefrom" id="dgAvailable_ctl02_lblpricefrom"><br>From <strong>£</strong></span></h5></div>

</div>

So i'm trying to hide the layer resultsitem if the text of dgAvailable_ctl02_lblpricefrom = £

Any help would be appreciated

Thanks

Jamie

+1  A: 

You can use closest like this:

if ($('#dgAvailable_ctl02_lblpricefrom > strong').text() == '£'){
    $('#dgAvailable_ctl02_lblpricefrom').closest('.resultsitem').hide()
}
Sarfraz
Thanks just what i needed
Jamie Taylor
A: 

The first parent of pricefrom is the h5 and then the container div. What I think you might want is:

$('#dgAvailable_ctl02_lblpricefrom').parents("div.resultsItem").hide();

I'd also note that hard coding your asp.net control IDs like this may cause you problems down the line...

Paddy
A: 

You can use parents()

if ($('#dgAvailable_ctl02_lblpricefrom > strong').text() == '£'){
    $('#dgAvailable_ctl02_lblpricefrom').parents('petspeoplecontainer').hide();
}
bcmcfc
A: 

Seems to work here. http://jsfiddle.net/SsVrE/

Litso