0

I try to trigger a click event if someone clicks on a an <a>nchor that has an <object> child:

$(function() {
    $("object").click(function() {
        alert("test");
        return false;
    });
});

The markup:

 <a>
   <object data="menu-item-2.svg" type="image/svg+xml"></object>
 </a>

I would expect that clicking on an <a> would trigger a click-event. It doesn't. Still, It would work with a mouseenter event.

How do I make it trigger a click event?


how to remove the loop attribute in a html 5 video tag with jquery

i have a page that uses videos in background and i have it set to loop on the main page.

i want to use JQuery to change the file and the attributes;

My code is

$("#garden").mouseover(function() {
    var videoFile = 'gardenlift.webm';
    $('#backgroundv video').attr({
        src: videoFile,
        loop: 'false'
    });

Its Not working! the second video still play in loop. How can i use jquery to remove the loop attribute

4

1 に答える 1

1

このようにできます。

ライブデモ

アンカー タグに href がありませんでした。

html の変更

<a href="#">aa
   <object data="menu-item-2.svg" type="image/svg+xml"></object>
</a>

Javascript

$(function() {
  $('a').each(function (){

  if($(this).children('object').length > 0)    
     $(this).click(function() {
         alert("test");
         return false;
  });
});
于 2012-06-09T17:22:53.027 に答える