2010-12-05 7 views
0

j'ai perdu un peu de temps pour arriver à savoir comment faire chose simple: Je voudrais obtenir un texte de certains lidiv.joomimg24_imgct div.joomimg24_txt ul li et se lient tout div de cette classe à un événement (je voudrais obtenir l'index de chaque div.joomimg24_imgct div si c'est possible). Par exemple, si j'ai:Obtenez des nœuds texte d'un div et lier un événement à un parent div

author : 0 
comments 1 

Je voudrais sauver 0 et 1 aux variables et se cacher div.joomimg24_txt, puis faire qqch avec les variables. Le truc, c'est que je ne peux même pas manipuler le div.joomimg24_txt.

J'ai déjà:

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(){ 
    } 
}) 
}); 

Répondre

3
jQuery("div.joomimg24_imgct option").hover(function() { 
    // mouse enter 

    var index = $(this).index(); 

}, function() { 
    // mouse leave 
}); 
+0

Y at-il moyen facile d'obtenir un élément d'un autre élément? – Damian

+0

@eaton Oui. '$ ('parent'). find ('sélecteur de l'enfant')'. – alex

0

Je me bats pour obtenir un effet que je veux pendant un certain temps, mais maintenant tous les travaux. Peut-être qu'il sera utile à quelqu'un: Il est un pop-up pour JoomImages (JoomGallery, Joomla), pour modifier la description pour un pop-up:

<?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; ?> 
Questions connexes