2010-12-05 18 views
0

にイベントをバインドし、私は単純なことを行う方法を知ってもらうためにいくつかの時間を無駄にしている: 私はいくつかdiv.joomimg24_imgct div.joomimg24_txt ul liとバインドからいくつかのテキストを取得したいのですがこのクラスのすべてのdivをイベントに設定します(可能ならdiv.joomimg24_imgct divのインデックスを取得したい)。私が持っている場合たとえば、 は:div要素のいくつかのテキストノードを取得し、親のdiv

author : 0 
comments 1 

私は変数でSTHを行い、その後、変数に0と1を保存し、div.joomimg24_txtを非表示にしたいと思います。 問題は、div.joomimg24_txtを操作することさえできないことです。

は私が既に持っている:

jQuery("div.joomimg24_imgct option").each(function() { 
jQuery(this).bind({ 
    mouseenter: function(){ 
    // get a text of each li in div.joomimg24_txt ul and save it, hide div 
    // jQuery(this).index(jQuery("div.joomimg24_txt")).hide(); //it dont work 
    // jQuery(this).(jQuery("div.joomimg24_txt")).hide();  //it dont work 
    // create a Pop-up, so I'd be nice to know x,y of *this* 

    }, 
    mouseleave: function(){ 
    } 
}) 
}); 

答えて

3
​​
+0

を別の要素を取得する簡単な方法があります素子? – Damian

+0

@eatonはい。 '$( 'parent')。find( '子セレクタ')'。 – alex

0

私は今、すべての作品を、私はいくつかの時間のために必要な効果を達成するために苦労されているが。多分それは誰かに有用であろう: それはポップアップにして説明を変更するJoomImages(JoomGallery、Joomlaの)、のためのポップアップです:

<?php if(JRequest::getVar('view') == "frontpage") : //You are in frontpage! Podmiana opisów?> 





<script type="text/javascript" src="jquery.qtip-1.0.0.js"></script> 



<script type="text/javascript" > 


jQuery("div.joomimg24_imgct").each(function() { 
     // $(this) = this current hyperlink 
//var elem = $(this).get(0); 
jQuery(this).find(".joomimg24_txt").hide(); 
// why it doesn't work on real page, works on static page 

var textField = jQuery(this).find(".joomimg24_txt ul li") ; 
var title = textField.get(0).innerHTML ; 
var author = textField.get(1).innerHTML.split(':')[1] ; 
var commnetsC = textField.get(3).innerHTML.split(':')[1] ; 

var newText = "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"\" class=\"box\"> \n\ 
<tbody><tr> <td class=\"tl\"></td> <td class=\"t\"> </td><td class=\"tr\"> \n\ 
</td></tr> <tr> <td class=\"l\"> </td><td class=\"content\"> <table width=\"30\"\n\ 
cellpadding=\"4\" style=\"width: x; margin: auto; font-size: 11px; line-height: 14px;\"> \n\ 
<tbody><tr> <td width=\"50\" class=\"td0\" style=\"width: 100px;\"> tytuł:</td> \n\ 
<td width=\"50\" class=\"td0\" style=\"width: 130px;\"><span class=\"td0\" style=\"width: 100px;\">\n\ 
" + title + "</span></td> </tr> <tr> <td class=\"td1\">autor:</td> <td class=\"td1\">\n\ 
" + author + "</td> </tr> <tr> <td class=\"td1\">ilość komentarzy</td> <td class=\"td1\">\n\ 
    " + " &nbsp&nbsp " + commnetsC +"</td> </tr> <tr> <td class=\"td1\">&nbsp;</td> <td class=\"td1\">&nbsp;</td> </tr> </tbody></table> </td> <td class=\"r\"> </td></tr> <tr> <td class=\"bl\"> </td><td class=\"b\"> </td><td class=\"br\"> </td></tr> </tbody></table>"; 



jQuery(this).qtip({ 
    content: newText, 
    show: 'mouseover', 
    hide: 'mouseout', 
    position: { 
     corner: { 
     target: 'bottomMiddle', 
     tooltip: 'topMiddle' 
     } 
    }, 

    style: { 
     width: 150, 
     padding: 2, 
     marginRight: 20, 
    // background: 'url("../images/bg-slide.jpg") repeat scroll 0 0 transparent', 
     background: 'url(/joomla/templates/upsilum/images/bg-slide.jpg)', 
     color: 'white', 

     border: { 
     width: 5, 
     radius: 4, 
     color: '#CCC' 
     } 


    } 

}) 







}) 



jQuery(".joomimg24_txt").hide(); 
// The firs try to hide doesnt work! Need to wait for all doc to read? 


</script> 

<?php endif; ?> 
関連する問題