Jump to content

jQuery check if html object contains already string


Mudsaf

Recommended Posts

If i got like code

var x= "info1";var y= "info2";$("example").on('click', function() {$("#content").append(x + y);});<div id="content"></div>

So if that content div would have alerady info1info2 data inside it it would not run the script.

var x= "info1";var y= "info2";$("example").on('click', function() { if (($"#content").BLABLABLABLBALAB) //if content doesn't have data already run$("#content").append(x);});<div id="content">info1info2</div>

Edited by Mudsaf
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...