Wazzzy Wazzzy - 7 months ago 11
Javascript Question

Using jQuery in a JavaScript function

function divlightbox(val)
{
if(val)
{
val=val.replace( /^\s+/g, "" );
var count_js=0;
var big_string='';
document.getElementById("video_lightbox").innerHTML="";
document.getElementById("divlightbox").style.display = "block";
$("#video_lightbox").css({"height":"430px","top":"10%","width":"480px"});


I found out that the error is in the above. My question is can't I use jQuery and traditional JavaScript at same time? I have done coding like this numerous times and never ran into a problem like this. I used to use jQuery methods like
.hide()
and
.css()
inside JavaScript functions but this time it doesn't work.

Thanks in advance.

Answer

to do things like hide(); and css() you need jquery objects. you can't do them to dom elements.

so you could do $('#video_lightbox').html(""); or

$('#video_lightbox').empty();