Jquery 获取div的一些文本节点并将事件绑定到父div
我已经浪费了一些时间去了解如何做简单的事情: 我想从一些liJquery 获取div的一些文本节点并将事件绑定到父div,jquery,jquery-selectors,Jquery,Jquery Selectors,我已经浪费了一些时间去了解如何做简单的事情: 我想从一些lidiv.joomimg24\u imgct div.joomimg24\u txt ul li获取一些文本,并将此类的所有div绑定到一个事件(如果可能的话,我想获取每个div.joomimg24\u imgct div的索引)。 例如,如果我有: author : 0 comments 1 我想将0和1保存到变量并隐藏div.joomimg24_txt,然后对变量进行处理。 问题是我甚至无法让div.joomimg24_txt进行
div.joomimg24\u imgct div.joomimg24\u txt ul li获取一些文本,并将此类的所有div绑定到一个事件(如果可能的话,我想获取每个div.joomimg24\u imgct div的索引)。
例如,如果我有:
author : 0
comments 1
我想将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(){
}
})
});
一段时间以来,我一直在努力达到我想要的效果,但现在一切都好了。也许它对某人有用:
它是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\
" + "    " + commnetsC +"</td> </tr> <tr> <td class=\"td1\"> </td> <td class=\"td1\"> </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; ?>
jQuery(“div.joomimg24_imgct”)。每个(函数(){
//$(this)=此当前超链接
//var elem=$(this.get)(0);
jQuery(this.find(“.joomig24_txt”).hide();
//为什么它不能在真实页面上工作,只能在静态页面上工作
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=“\n\
\n\
\n\
蒂图什:\n\
\n\
“+title+”自动转发器:\n\
“+作者+”ilośćkomentarzy\n\
“+”+commnetsC+”;
jQuery(this).qtip({
内容:新文本,
显示:“鼠标悬停”,
隐藏:“鼠标出”,
职位:{
角落:{
目标:'底部中间',
工具提示:“topMiddle”
}
},
样式:{
宽度:150,
填充:2,
marginRight:20,
//背景:“url(../images/bg slide.jpg”)重复滚动0 0透明”,
背景:“url(/joomla/templates/upsilum/images/bg slide.jpg)”,
颜色:'白色',
边界:{
宽度:5,
半径:4,
颜色:“#CCC”
}
}
})
})
jQuery(“.joomig24_txt”).hide();
//冷杉想躲起来却没用!需要等待所有文档读取吗?
一段时间以来,我一直在努力实现我想要的效果,但现在一切都正常了。也许它对某人有用:
它是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\
" + "    " + commnetsC +"</td> </tr> <tr> <td class=\"td1\"> </td> <td class=\"td1\"> </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; ?>
jQuery(“div.joomimg24_imgct”)。每个(函数(){
//$(this)=此当前超链接
//var elem=$(this.get)(0);
jQuery(this.find(“.joomig24_txt”).hide();
//为什么它不能在真实页面上工作,只能在静态页面上工作
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=“\n\
\n\
\n\
蒂图什:\n\
\n\
“+title+”自动转发器:\n\
“+作者+”ilośćkomentarzy\n\
“+”+commnetsC+”;
jQuery(this).qtip({
内容:新文本,
显示:“鼠标悬停”,
隐藏:“鼠标出”,
职位:{
角落:{
目标:'底部中间',
工具提示:“topMiddle”
}
},
样式:{
宽度:150,
填充:2,
marginRight:20,
//背景:“url(../images/bg slide.jpg”)重复滚动0 0透明”,
背景:“url(/joomla/templates/upsilum/images/bg slide.jpg)”,
颜色:'白色',
边界:{
宽度:5,
半径:4,
颜色:“#CCC”
}
}
})
})
jQuery(“.joomig24_txt”).hide();
//冷杉想躲起来却没用!需要等待所有文档读取吗?
有没有从另一个元素获取元素的简单方法?@eaton有<代码>$('parent')。查找('child selector')
。有没有从另一个元素获取元素的简单方法?@eaton有<代码>$('parent')。查找('child selector')
。