2013-03-16 17 views
2

是否可以将'data-description'更改为div类?但仍然使脚本工作,因为我希望把数据描述的URL和图像div数据中的jquery图像或url-

请帮我

<script type="text/javascript"> 
    $(document).ready(function() { 
     $("#MenuBar1 div").mouseover(function() { 
      $('.description').text($(this).data('description')); 
     }).mouseout(function() { 
      $("#back").attr("src", $("#back").data("original")); 
     }); 
    }); 
</script> 

<div id="MenuBar1" class="MenuBarHorizontal"> 
    <div data-description="Beschrijving 1"> 
    <a href="#">Titel 1</a> 
    </div> 

    <div data-description="Beschrijving 2"> 
    <a href="#">Titel 2</a> 
    </div> 

    <div data-description="Beschrijving 3"> 
    <a href="#">Titel 3</a> 
    </div> 
</div> 

<div class="description"> 
Text change. 
</div> 
+0

是什么'#back'和谁正在更改值 – 2013-03-16 17:39:53

回答

0

试试这个

$('#elementID').data('description','urlyou want'); 
+0

如何将其放入我的代码中?对不起,我只是一个初学者 – 2013-03-16 18:25:17

+0

混淆了你真正需要的东西....你可以请详细说明 – bipen 2013-03-16 18:31:07

+0

当我将鼠标悬停在标题上1 .. Beschrijving 1显示div .description。当我悬停在标题2 .. Beschrijving 2节目说明等显示,但我不能把任何图像的HREF标签数据描述(这将显示在div .description)。我怎样才能做到这一点? – 2013-03-19 15:02:29