Apply css on enabled buttons JavaScript

0 votes
asked Sep 13, 2017 by vikram

I have HTML page where div and buttons are generating dynamically from JavaScript as below.

<div style="background: rgb(247, 247, 247);"> <button class ="xyz" disabled="disabled">Button1</button>
<div style="background: rgb(247, 247, 247);"> <button class ="xyz" disabled="disabled">Button2</button>
<div style="background: rgb(247, 247, 247);"> <button class ="xyz">Button3</button>

My requirement is to change the css(background color) of that div only in which Button is not disabled which is last div. I'm using jQuery to do this but it is changing css for all the divs above. Please tell me the solution for this requirement in jQuery or JavaScript.

$(".xyz").parent().css({ "background": "rgb(95, 49, 49)" }); 

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter