Mudsaf Posted February 15, 2013 Share Posted February 15, 2013 (edited) 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 February 15, 2013 by Mudsaf Link to comment Share on other sites More sharing options...
justsomeguy Posted February 15, 2013 Share Posted February 15, 2013 I'm not sure what you're asking, but this line is not syntactically correct: if (($"#content").BLABLABLABLBALAB) Link to comment Share on other sites More sharing options...
dsonesuk Posted February 15, 2013 Share Posted February 15, 2013 Try search() if ($('#content').html().search(x) ==-1 && $('#content').html().search(y) ==-1) Link to comment Share on other sites More sharing options...
callumacrae Posted February 15, 2013 Share Posted February 15, 2013 or .text() Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now