[英]after adding DOM manipulation before ajax call, the dom is not retaining after ajax
Current Flow ScreenShoot for Ref : 当前流ScreenShoot为参考:
Iam Adding a class to element and trying to give focus. Iam将一个类添加到element并尝试给予焦点。 for static elements its working fine.
对于静态元素,其工作正常。 but whenever i call ajax request.
但是每当我打电话给ajax请求时。 the class which i added is not retaining its getting removed.
我添加的类不保留其被删除。
JS : JS:
$('#search-refine-bar').on('click', function(e) {
var eventNode = e.target.nodeName;
$('.highlight').removeClass('highlight').removeAttr('tabindex focus style').css({
"border": ""
});
setTimeout(function() {
alert(eventNode + " --------------- " + 'In Progress adding focus');
$(e.target).attr({
tabindex: "-1",
focus: "focus"
}).addClass('highlight').focus().css({
"border": "1px solid #f00"
});
alert(eventNode + " --------------- " + 'Done status')
}, 1000);
});
After the first click, everything look fine for me. 第一次点击后,一切对我来说都很好。
Your click event is on the div that contains everything, so you are marking also <p>
tags etc. Im not sure if you want this... 您的click事件在包含所有内容的div上,因此您还标记了
<p>
标记等。我不确定是否要这样做...
The probelm is, when you click agian some where, you are delting everything with this code... 问题是,当您在某处单击agian时,您将使用此代码删除所有内容...
$('.highlight').removeClass('highlight').removeAttr('tabindex focus style').css({
"border": ""
});
And im not sure what you are trying to accomplish with this code.. 而且我不确定您要用此代码完成什么。
Im just guessing, are you trying something like this fiddle: http://jsfiddle.net/589hq620/ 我只是猜测,您是否正在尝试类似这种提琴手: http : //jsfiddle.net/589hq620/
But for your question, removing this code is the answer... 但是对于您的问题,删除此代码才是答案……
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.