修改元素的属性 [英] Modify attribute of element

查看:90
本文介绍了修改元素的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否存在一种使用Lift中的JsCmd修改元素(例如select)的属性的方法.

I would like to know if there exists a way to modify the attributes of an element (for example a select) using a JsCmd in lift.

这是我现在拥有的运行javascript字符串的工作版本.

Here the working version I have for now, running the javascript string.

Run("document.getElementById(\"select_id\").setAttribute(\"width\", \"30px\");")

提前谢谢.

推荐答案

您可以使用Lift中包含的JqJE库,该库提供了围绕JQuery的程序化包装.

You can use the JqJE library included in Lift which provides a programatic wrapper around JQuery.

以下代码段将创建一个链接,当单击该链接时,会将#select_idwidth属性设置为30px.

The following snippet will create a link that will set the width attribute of #select_id to 30px when clicked.

"#link *" #> a( () => JqId("select_id") ~> JqAttr("width","30px"), Text("clickme"))

此代码段提供了完整的示例: https://gist.github.com/725432

This code snippet provides a full example: https://gist.github.com/725432

这篇关于修改元素的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆