目前我有一个功能,完美的IE浏览器,Chrome浏览器和Safari浏览器,以获得我将重点放在一个GridView的文本框的ID名称。替代event.srcElement.id
function onTextFocus() {
alert(event.srcElement.id);
}
功能是为GridView一个的RowDataBound时呼吁:
protected void ItemGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((TextBox)e.Row.FindControl("txtQuantity")).Attributes.Add("onfocus", "onTextFocus();");
}
}
但是它并不适用于Firefox的工作,因为它不承认srcElement。所以我正在寻找一种适用于所有浏览器的替代方案。淘宝谷歌后,我想出了这些替代品,但我得到一个未定义的错误或ReferenceError。任何想法为什么?
function onTextFocus() {
alert(this.id);
alert(event.currentTarget.id);
alert(event.target.id);
alert(event.currentTarget);
alert(event.target);
alert($(this).attr('id'));
alert($(obj).attr("id"));
alert($(this).id);
alert($(this).get(0).id);
alert($(this).prop("id"));
}
显示您在哪里如何使用方法 – Satpal
是问题解决了,可还是需要一些帮助? –