javascript - How to get text of this element not the child -


i want hide text first text only, using (opacity:0) when mouse on topblock.

<div class="topblock">    first text    <div class="block">       inner text    </div> </div> 

but when use following jquery code getting child div text first text inner text

$(".topblock").on("mouseenter",function(){     console.log($(this).text());     $(this).css({"opacity":"0"}) }).on("mouseleave",function(){  }); 

to require without amending html structure exceptionally difficult need amend textnode holding first text value directly.

instead far simpler amend html wrap text in element, such span, , perform operations on element. try this:

<div class="topblock">    <span>first text</span>    <div class="block">       inner text    </div> </div> 
$(".topblock").on("hover",function(){     $(this).find('span').toggle(); }); 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -