Q:

jQuery if statement show/hide

I got a code like this that copies inside text to another div.
 var MyDiv1 = document.getElementById('myModal');
 var MyDiv2 = document.getElementById('purchaseNotice');
 MyDiv2.innerHTML = MyDiv1.innerHTML;

The div with id 'purchaseNotice' is sitting within a template, it also has a styling class of the box, however I need to create an if statement that checks if the id 'myModal' exist then show 'purchaseNotice' with class (else) hide it all.
If there was a way of adding a div with class between the text that is copied to 'purchaseNotice' that would solve my problem.
@UPDATE
Here is a link to what I have:
http://jsfiddle.net/A9FE8/
Try to make an if statement to show the styling of the 'infobox' only if the id 'myModal' exist, otherwise hide.

A:

do you mean like:
if( $("#myModal").length ) { //check if div with id "myModal" exists
  $("#purchaseNotice").addClass("some_class").show();
}
else {
   $("#purchaseNotice").hide();
}

