0

Need to style id="Parent" based on id="child" Kindly check with code for more understanding.

I'm using uniform.js for form control

when we write

<select id="child"  class="input-validation-error">
    <option value="">Select</option>
    <option value="1">Procurement</option>
    <option value="2">Cost Synergy</option>
    <option value="3">Revenue Synergy</option>
    <option value="4">Procurement Enabled Cost Synergy</option>
</select>

It Generates below code

<div id="parent" class="selector">
<span>Select</span>
<select id="child"  class="input-validation-error">
<option value="">Select</option>
<option value="1">Procurement</option>
<option value="2">Cost Synergy</option>
<option value="3">Revenue Synergy</option>
<option value="4">Procurement Enabled Cost Synergy</option>
</select>
</div>

Can you please help me Thank you :)

Harshad
  • 99
  • 2
  • 9
  • you want to change parent class css according to child? – Leo the lion Jul 21 '15 at 05:31
  • Yes you right :) want to change styling of parent based on child. – Harshad Jul 21 '15 at 05:34
  • 2
    There is no selector in CSS that allows you to style a parent based on whether an element contains a certain child. Can you do it a different way (add a different class to the parent)? Would you be open to a jquery solution? – AndrewR Jul 21 '15 at 05:37
  • yes we can do very well using Jquery. but i don't want to use jquery because there are many jscript are running in my project. – Harshad Jul 21 '15 at 05:53
  • I wouldn't want to use jQuery/javascript for this either. Your only option is to add a specific class to the ones you want to style differently. – AndrewR Jul 21 '15 at 06:01
  • I have updated the above Question...Please go through. – Harshad Jul 21 '15 at 07:28

1 Answers1

0

attach an onchange="function(this)" with the child. define the function(this) in your js script. there you can simply do getElementById("parent").style.xyz='xyz'.

GOOD LUCK!!

kingshuk basak
  • 423
  • 2
  • 8