Hi Mudassar,
I have the below Jqeury for adding a textbox, which will be placed in a div
----------------------------------------------------------------------------
<script type="text/javascript">
var counter = 0;
function GetDynamicTextBox(value) {
return '<input name = "DynamicTextBox" class="dynamictb" id=tb_new' + counter + '" type="text" value = "' + value + '" />' +
'<img id="btnDel' + counter + '" class="delbtn" src="Pictures/btnDel.png" alt="Del" onclick="RemoveTextBox(this)" />'
}
function AddTextBox() {
var div = document.createElement('DIV');
div.setAttribute("class", "pn_new");
div.innerHTML = GetDynamicTextBox("");
document.getElementById("tbGroup").appendChild(div);
counter++;
}
function RemoveTextBox(div) {
document.getElementById("tbGroup").removeChild(div.parentNode);
if (counter > 0) {
counter--;
}
return false;
}
function RecreateDynamicTextboxes() {
var values = eval('<%=Values%>');
if (values != null) {
var html = "";
for (var i = 0; i < values.length; i++) {
html += "<div>" + GetDynamicTextBox(values[i]) + "</div>";
}
document.getElementById("TextBoxContainer").innerHTML = html;
}
}
window.onload = RecreateDynamicTextboxes;
</script>
----------------------------------------------------------------------------
This is the Jquery that i trigger the effect
(whenever hover, the pic will be change from 123.jpg to 123a.jpg
----------------------------------------------------------------------------
function imghover(tar) {
$(tar).find('img').hover(function () {
var current = $(this).attr('src').slice(0, $(this).attr('src').lastIndexOf('.png'));
$(this).attr('src', current + 'a.png');
}, function () {
var current = $(this).attr('src').slice(0, $(this).attr('src').lastIndexOf('a.png'));
$(this).attr('src', current + '.png');
});
}
$(document).ready(function () {
imghover('.imagebtn'); imghover('.pn_new');
});
----------------------------------------------------------------------------
Basically, as i tested, the first 2 textbox are generated dynamically by ASP.NET code behind.
the Jquery works well and sucessfully.
However, as you see, the 3rd textbox, generated by jquery doesnt change the pic to 123a.jpg. I see that both have the same structure and should work..Quite weird.
And i tried used class of imagebtn & pn_new to trigger. Both doesnt work
Thanks in advance!