Friday, 15 January 2010

javascript - Traversing Using Jquery .find() to Select Element by Class & Store Prop -


I want to find a specific element with the title "Classroom" to search through the descendant of the "Service-Block" element "Using the code below. I can not get anything from var but "undefined" is assigned. Any help would be greatly appreciated -

  & lt; Div class = "col-md-4" & gt; & Lt; Div id = "service-block" class = "wp-block default gray-glow" & gt; & Lt; Div class = "shape" & gt; & Lt; IMG alt = "..." src = "~ / images / services / nav-icon-white.jpg" class = "img-responsive" & gt; & Lt; / Div & gt; & Lt; Div class = "wp-block-body services-text" & gt; & Lt; H2 id = "test" class = "title" & gt; Lorem Ipsum & lt; Span class = "heavy-header" style = "color: # 001990;" & Gt; Lorem Ipsum & lt; / Span & gt; Lorem Ipsum & lt; / H2 & gt; & Lt; P & gt; Lorem Ipsum & Lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; $ ("# Service-block") hover (function () {var originalHeight = $ (this) .find ('. Title') .prop ("id");});  

Do you want it?

  $ ("# service-block"). Hover (function () {var $ elem = $ (this) .find ('.title'); console.log ("element id:", $ elem.attr ("id"); Console.log (" Element height: ", $ elem.height ()); // added due to your variable name}};  

No comments:

Post a Comment