简体   繁体   中英

Hid first div with specific content after body tag - no id or classname

I have a div that appears on my site from a compiled module which I can't edit. I just want to hide this div for now - eventually the module will be replaced.

The div does not have a classname or id but on the pages it appears on it is the first dv after the body tag and starts out like so

<div align="right">
<font size="-2" color="#808080">
Found session: 

I don't want to inadvertantly hide some other div if it appears on one of the site pages so was hoping there is some way to use the above data - perhaps 'if div contains "Found session:" to make sure it is the right div and hide it. I don't know jquery mostly just use existing script with minor tweaking so would appreciate detailed response.

Try

$('body div').first().filter(':contains("Found session:")').hide()

$('body div').first() finds the first div within the body element and the filter() will make sure the element contains the text Found session:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM