6
如何将自定义属性添加到Wordpress wp_editor textarea字段?如何将自定义属性添加到Wordpress wp_editor文本区?
在官方文档中没有办法做到这一点。我需要添加客户端验证属性(data-bvalidator =“required”)到由wp_editor WordPress生成的文本区域。
有什么建议吗?
如何将自定义属性添加到Wordpress wp_editor textarea字段?如何将自定义属性添加到Wordpress wp_editor文本区?
在官方文档中没有办法做到这一点。我需要添加客户端验证属性(data-bvalidator =“required”)到由wp_editor WordPress生成的文本区域。
有什么建议吗?
我觉得有没有添加自定义属性在wp_editor()
所以你需要添加使用JQuery
首先添加额外的类(ES)的编辑text-area
场自定义属性的选项text-area
$settings = array(
......
'editor_class' => 'customclass_for_addattr',
......
);
wp_editor($content, $editor_id, $settings );
在wp_editor()函数之后添加下面的jQuery代码。它将自定义属性添加到text-area
使用jQuery atrr
方法
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".customclass_for_addattr").attr('data-bvalidator','required');
});
</script>