我有一个javascript代码,用户无法使用它,所以我提供了帮助并访问了他的网站。发现title="-arabic-"
和我的代码title="Male"
所以在这里质疑,如果我使用标题的复制和粘贴并将其放在我的 javascript 中,它实际上会搜索阿拉伯语版本还是我必须做一些额外的事情?
$(document).ready(function() {
var $postBG = $('.post .poster-profile img');
$postBG.filter('[title="ذك"]').closest('td').addClass('male').children('td').removeClass('row1').removeClass('row2');
$postBG.filter('[title="انثى"]').closest('td').addClass('female').children('td').removeClass('row1').removeClass('row2');
});
这是我开始使用的代码,正如您在标题点中看到的阿拉伯语。
IMG来源:雄
<img src="http://i49.servimg.com/u/f49/14/49/52/30/male210.gif" alt="ذكر" title="ذكر">
女性
<img src="http://i49.servimg.com/u/f49/14/49/52/30/female11.gif" alt="انثى" title="انثى">
$(document).ready(function() {
var $postBG = $('.post #profil_body img');
$postBG.filter('[title="ذك"]').closest('td').removeClass('row1').removeClass('row2').find('#profil_body').removeAttr('id').addClass('male');
$postBG.filter('[title="انثى"]').closest('td').removeClass('row1').removeClass('row2').find('#profil_body').removeAttr('id').addClass('female');
});
首先,我切换了查找的位置,.post .poster-profile img
似乎还可以,但我想打开搜索,所以我将其切换到.post #profil_body img
从而更快地找到图像。
我首先要做的是,如果在最近的td
中发现男性和女性的阿拉伯语案例,以删除类row1
row2
然后.find
围绕 img 的div,并且removeAttr('id')
因为该 id 干扰了其他所有内容,因此具有背景图像。
完成所有操作后,我们将相应的类添加到td
现在,javascript .filter
可以正常工作,以满足我需要做的事情!
感谢大家的好建议和想法,帮助我获得了思路!