我在wordpress编辑器中构建页面,我需要添加这段代码
<input style="width: 10%; border: none; font-weight: bold; color: #757575;" type="text" value="1" onchange="changeQuantity(this.value,1);" />
当我输入编辑页面 - &gt;文字它运作正常,但只有当我点击视觉并返回文字时,上面发布的代码才会变为:
<input style="width: 10%; border: none; font-weight: bold; color: #757575;" type="text" value="1" />
没有
onchange="changeQuantity(this.value,1);"
我无法理解为什么会发生这种情况。
答案 0 :(得分:0)
As I read on this page, seems like you can install a plugin called Raw HTML which can help you in this situation. One guy here says, and I quote:
Now, from my understanding ( unless things have changed recently ) the default editor doesn’t allow any Javascript for security purposes which means that you will lose the onclick="".
So maybe you shouldn't use it.
If you still want to use it, after you install the plugin you can insert the code like this in the text tab, and it should work:
[raw]<input style="width: 10%; border: none; font-weight: bold; color: #757575;" type="text" value="1" onchange="changeQuantity(this.value,1);" />[/raw]