开发者

Get some text nodes of a div and bind an event to a parent div

I have wasted some time to get to know how to do simple thing: I'd like to get some text from some li div.joomimg24_imgct div.joomimg24_txt ul li and bind all div of this class to an event (I'd like to get index of each div.joomimg24_imgct div if it is possible)开发者_开发技巧. For example if I have:

author : 0 
comments 1

I'd like to save 0 and 1 to variables and hide div.joomimg24_txt, then do sth with the variables. The thing is that I even can't get the div.joomimg24_txt to manipulate.

I already have:

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


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

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

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


I have been struggling to achieve effect I want for some time, but now all works. Maybe it will be useful to someone: It is a pop-up for JoomImages (JoomGallery, Joomla), to change the description in to a 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; ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜