I am trying to click on a div while contains a specific text.
This is where I am:
$( document ).ready(function() {
$('.myclass li.active .short-text'["value=thetext"]).click();
});
The code above is not doing it ... How can I get this to work?
I am trying to click on a div while contains a specific text.
This is where I am:
$( document ).ready(function() {
$('.myclass li.active .short-text'["value=thetext"]).click();
});
The code above is not doing it ... How can I get this to work?
 
    
    You can use contains-selector
Select all elements that contain the specified text.
$('.myclass li.active .short-text:contains("someText")').click();
 
    
    this is the jquery method of checking if something contains a text. i don't know if you can use it as a click function though
   $('.myclass li.active .short-text:contains("thetext")').click();
 
    
    Something like this should do the trick. Not sure if there is a better solution.
$(document).ready(function() {
    $("div").click(function() {
        if($(this).text() == "The text") {
            //Code here
        });
    });
});
