我已经根据我收集到的一些东西在这里进行了尝试,但这只是完全删除它;标题不会返回 <= 768px
<script>
if( $(window).width() > 767) {
$('[title]').each( function() {
var $this = $(this);
$this.data('title',$this.attr('title'));
$this.removeAttr('title');
});
}
</script>
最佳答案
if ($(window).width() > 767) {
$('[title]').each( function() {
var $this = $(this);
$this.data('title',$this.attr('title'));
$this.removeAttr('title');
});
} else {
// as in above `title` attribute removed and `data-title` added, so now you've
// to loop with data-title
$('[data-title]').each( function() {
var $this = $(this);
$this.data('title',$this.data('title'));
$this.removeAttr('data-title');
});
}
关于javascript - 根据屏幕宽度隐藏链接标题属性 - 不会取消隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27072232/