My house is as follows:
<div class="blah"> <a href=""><img .. ></a> <strong>blah blah</strong> <a href=""><img /></a> </div>
How can I get the value of strong when I know that the class is “blah”?
$(".blah").find("strong") does not work?
$(".blah").find("strong")
Try the following:
$(".blah").find("strong").html();
$ (". blah"). find ("strong") will return a jQuery object, not the content.
var value = $('.blah strong').html();
It's easier than pim to answer, but it works courageously the same. It finds all descendants of .blah, which are strong tags, and returns the html content of the first.
try it
<script type="text/javascript"> $(document).ready(function() { alert($(".blah > strong").text()); }); </script> <div class="blah"> <a href="#"> <img src="#" /></a> <strong>blah blah</strong> </div>
Source: https://habr.com/ru/post/1705154/More articles:Is there any way to set variables in ssh? - mysqlHelp my users find the installer on the CD - installerOrder with the Collate OfferEmulating Vista Notification Icon Dialog Boxes Using WPF - wpfHow to get information from the checkbox? - checkboxEclipse RCP - How to Open Launch Settings Dialog - eclipse-pluginHow to add space between two related NSStrings? - objective-cWhat does the number of processor ways mean - cpuhighlight text in html with javascript jQuery - javascriptЗаблокировать определенные методы/типы - compiler-constructionAll Articles