سؤال

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

هل كانت مفيدة؟

المحلول

I think you want .find() not .next():

$('[DEF="veyron_colour_change"]').find('[diffuseColor]').attr('diffuseColor', '0.2118 0.1569 0.9333');

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top