jQuery 选择问题
只是想知道你是否能帮忙。
我有以下代码:
<transform DEF='veyron_colour_change' rotation='0.2815 -0.6785 0.6785 -3.69' scale='0.2107 0.2107 0.2107' translation='-2.291 26.33 19.26'>
<shape>
<appearance>
<material ambientIntensity='1' diffuseColor='1 0.1255 0.1255' shininess='0.3825' specularColor='1.215 1.215 1.215'></material>
</appearance>
<indexedFaceSet creaseAngle='1' DEF='veyron_colour_change-FACES'...
我正在尝试使用 jQuery 选择材质元素以更改 diffeColor 属性。我尝试执行此操作的代码是:
$('[DEF="veyron_colour_change"]').next('[diffuseColor]').attr('diffuseColor', '0.2118 0.1569 0.9333');
但它不起作用。有什么想法吗?
谢谢
was just wondering if you could help.
I have the following bit of code:
<transform DEF='veyron_colour_change' rotation='0.2815 -0.6785 0.6785 -3.69' scale='0.2107 0.2107 0.2107' translation='-2.291 26.33 19.26'>
<shape>
<appearance>
<material ambientIntensity='1' diffuseColor='1 0.1255 0.1255' shininess='0.3825' specularColor='1.215 1.215 1.215'></material>
</appearance>
<indexedFaceSet creaseAngle='1' DEF='veyron_colour_change-FACES'...
I am trying to select the material element using jQuery in order to change the diffuseColor attribute. The code im trying to do this with is:
$('[DEF="veyron_colour_change"]').next('[diffuseColor]').attr('diffuseColor', '0.2118 0.1569 0.9333');
But it isnt working. any ideas?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您想要
.find()
而不是.next()
:具有该属性的元素(在本例中为
>) 是
元素的后代,因此您可以使用.find()
来定位它。.next()
表示它出现在元素之后,而不是出现在元素内部。I think you want
.find()
not.next()
:The element with that attribute (in this case,
<material />
) is a descendant of the<transform />
element, so you use.find()
to locate it..next()
means it comes after the element rather than occurring inside it.