[英]Why javascript function inside new page is not working?
I have options page which opens with this: 我有打开的选项页面:
<li class="small-icon options-panel"><a class='options-page' href="{TRESNJAPANEL_LINK}"
title="Tresnja Options Panel" role="menuitem" onclick="window.open('{TRESNJAPANEL_LINK}',
'newwindow', 'width=300, height=250, resizable=yes ,
scrollbars=yes'); return false;"><i class="fa fa-diamond"
aria-hidden="true"></i>Tresnja Options Panel</a></li>
so when i open options page i have some options and functions with checkbox, inputs etc... 所以当我打开选项页面时,我有一些带有复选框,输入等的选项和功能...
and i have function: 我有功能:
function stickyheaddsadaer(obj) {
if($(obj).is(":checked")){
alert("Yes checked"); //when checked
$("#page-header-inner").addClass("sticky");
}else{
alert("Not checked"); //when not checked
}
}
<input type="checkbox" name="TT_sticky_header" id="TT_sticky_header_function"
value="{TT_sticky_header}" onclick="stickyheaddsadaer()"/>
this function only works inside options page, because when i click save and exit options page, it does not work on normal page... 此功能仅在选项页面内有效,因为当我单击“保存并退出选项”页面时,在正常页面上不起作用...
or if i put this function including input type="checkbox" outside options page, then again works.... 或者,如果我将此功能(包括输入类型=“复选框”)放在选项页面之外,则可以再次使用...。
please help me what i need to do get working javascrip inside options page ? 请帮助我,我需要做的事情才能在选项页面中使用javascrip吗?
Thank you 谢谢
You have missed this
inside stickyheaddsadaer()
and its better to use onchange
not onclick
. 你错过了
this
里面stickyheaddsadaer()
和更好地使用onchange
不会onclick
。
use this:
用这个:
<input type="checkbox" name="TT_sticky_header" id="TT_sticky_header_function"
value="{TT_sticky_header}" onchange="stickyheaddsadaer(this)"/>
instead of:
代替:
<input type="checkbox" name="TT_sticky_header" id="TT_sticky_header_function"
value="{TT_sticky_header}" onclick="stickyheaddsadaer()"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.