I am trying to create a if statement that triggers a alert box if there is text in the div.
My Jsfiddle: http://jsfiddle.net/D7cPT/21/
My HTML:
<div id="post-preview">aasasdasd</div>
MY JQUERY:
$(document).ready(function() {
// Bind it to some action.
if{$('#post_body_html').html();) {
alert('asdasda');
}
});
OH DEAR GOD:
How about:
Also your selector doesn’t match the ID of your element. Change
#post_body_htmlto#post-previewjsFiddle
Edit:
To those who land here later on, a better way to accomplish the same test is written:
instead.