Thursday, June 4, 2009

[jQuery] Re: Inner HTML on a .bind()

Try this:
$('object').click(function(){
  $(this).find('embed').css({width:500px,height:500px});
});

2009/6/4 AndyW <awysocki@absoftware.com>

My page basically puts in a few YouTube videos on my page

<object class="YTV" ...><param ...></param><param ...></param><embed
height="" width=""...></embed></object>
<object class="YTV" ...><param ...></param><param ...></param><embed
height="" width=""...></embed></object>
<object class="YTV" ...><param ...></param><param ...></param><embed
height="" width=""...></embed></object>


In my document ready function I do the following

$("object.YTV > *").bind('click', function(e){

 alert( $(this).html() );  /* this show the HTML code within the
OBJECT tag */

 var emb1 = $(this).contains("embed").html();
 var emb2 = $("embed", this).html();

 alert( emb1 );
 alert( emb2 );

});


My end goal is to change the width and height of the <EMBED ...> tag
like they do on FaceBook where when you click on a video, the video
display gets bigger.

Since there are a few of these objects on the page. How in my bind
(click) code do I figure out and update the EMBED tag that is
contained within the OBJECT tag.

If I set the EMBED tag with a unique ID= I can update it, but for the
life of me I'm missing how to parse out the inter HTML code that is
within the OBJECT tag that I can see in my $(this).html() ?

Thanks
Andy



--
Gustavo Salome Silva

No comments: