Javascript 单击“范围”后打开文本字段无效
我无法使用JavaScript/jQuery创建就地编辑功能。我无法使用插件editinplace,因为我需要在其上放置一个日期选择器。由于某些奇怪的原因,我下面的代码不起作用:Javascript 单击“范围”后打开文本字段无效,javascript,jquery,edit-in-place,Javascript,Jquery,Edit In Place,我无法使用JavaScript/jQuery创建就地编辑功能。我无法使用插件editinplace,因为我需要在其上放置一个日期选择器。由于某些奇怪的原因,我下面的代码不起作用: function editImpfDatumImpfung1Clicked(sender) { var sText = $(this).text(); var sId = $(this).attr("id"); $(this).attr("id", "tobechanged"); $(t
function editImpfDatumImpfung1Clicked(sender)
{
var sText = $(this).text();
var sId = $(this).attr("id");
$(this).attr("id", "tobechanged");
$(this).after('<input type="text" id="' + sId + '" value="' + sText + '" />');
$(this).remove();
bImpfung1Clicked = true;
$("#" + sId).focus();
$("#" + sId).datepicker(datepickerOptions);
if (bFirstRegisterImpfung1 === true)
{
firstRegisterImpfung1();
bFirstRegisterImpfung1 = false;
}
}
$(document).ready(function()
{
$elem = $("span[id^='impfung_1['");
if ($elem.length > 0)
{
bFirstRegisterImpfung1 = true;
$elem.click(editImpfDatumImpfung1Clicked);
}
});
谢谢你的建议。我想你在以下几行中有一个打字错误:
$elem = $("span[id^='impfung_1['");
请尝试以下方法:
$elem = $("span[id^='impfung_1']");
控制台上的任何错误提供错误将有助于解决您的问题。您能否提供一个?相关/代表性HTML是什么?以及单个报价?
$elem = $("span[id^='impfung_1']");