我希望以下代码在我的joomla网站的其中一个paegs中运行。当用户点击带有相关名字的第四列时,此代码只是打开一个表单....我将此代码直接添加到我的joomla文章HTML的末尾,在phpmyAdmin中,因此不会过滤js代码。
jQuery(document).ready(function ($) {
jQuery(".oldPeople tr:not(.oldPeople tr:first)").each(function (i) {
//code
jQuery(this td:nth-child(4)).css('cursor', 'pointer');
jQuery(this td:nth-child(4)).click(function () {
var fname = jQuery(this td: nth - child(1)).html();
var lname = jQuery(this td: nth - child(2)).html();
var dep = jQuery(this td: nth - child(3)).html();
var str = encodeURI("http://alumsharif.org/index.php?option=com_rsform&formId=38&form[fname]=" + fname + "&form[lname]=" + lname + "&form[dep]="dep);
jQuery(this td:nth-child(4)).replaceWith(str);
window.open(str);
}); //click
}); //each
}); //ready
,网页是: http://alumsharif.org/index.php?option=com_content&view=article&id=230&Itemid=2011
但代码不起作用..当我把console.log放在每个函数里面时没有任何事情发生...我不知道我是否错过了......
答案 0 :(得分:0)
抱歉我的代码中存在愚蠢和基本的错误: 我纠正了我的代码,并在任何人需要的时候发布它
jQuery(document).ready(function($) {
jQuery(".oldPeople tr:not(.oldPeople tr:first)").each(function(i) {
//code
var tr = jQuery(this);
jQuery(this).children("td:nth-child(4)").css( 'cursor', 'pointer' );
jQuery(this).children("td:nth-child(4)").click(function(){
var fname = tr.children("td:nth-child(1)").text();
console.log(fname);
var lname = tr.children("td:nth-child(2)").text();
var dep = tr.children("td:nth-child(3)").text();
var str = "http://alumsharif.org/index.php?option=com_rsform&formId=38&form[fname]="+encodeURI(fname)+"&form[lname]="+encodeURI(lname)+"&form[dep]="+encodeURI(dep);
//jQuery(this).children("td:nth-child(4)").replaceWith(str);
window.open(str,' ارسال اطلاعات' + fname + " " +lname, 'width=600, height=600');
console.log(str);
});//click
});//each
});//ready