Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Google Pixel 9 Pro
vgp
Updated:
Thursday at 5:57 PM
Ad icon
Jobreceive.com for sale
Blogerwiki
Updated:
Tuesday at 8:55 PM
Post Your Vehicle for Sale — FREE! - https://libro.lk
Kalu_Puth
Updated:
Tuesday at 7:38 PM
ඔයාගෙ Assignment හෝ Thesis එක හරියට හදාගමු
ErMurazor
Updated:
Sep 26, 2026
Ad icon
BlackWall V2ray servers
hu KANNA
Updated:
Sep 23, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
මේ Code එකේ අවුල මොකක්ද HTML, JS, CSS
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="ryangate2" data-source="post: 28972633" data-attributes="member: 579789"><p>The issue with your code is the use of `!important` within JavaScript to change CSS styles. The `!important` rule is a part of CSS and it's not supposed to be used with JavaScript in this way. It has no effect in JavaScript and can cause your code not to work as expected.</p><p></p><p>Here's the correct code:</p><p></p><p>```javascript</p><p>const selectElementOrc1 = document.getElementById('meta_orcapplicable');</p><p>const displayElementOrc1 = document.getElementById('new_orcincluded');</p><p></p><p>selectElementOrc1.onchange = function() {</p><p> if (selectElementOrc1.value === 'Applicable') {</p><p> displayElementOrc1.style.display = 'block';</p><p> } else {</p><p> displayElementOrc1.style.display = 'none';</p><p> }</p><p>};</p><p>```</p><p></p><p>This will show and hide your `displayElementOrc1` based on the value of `selectElementOrc1`. However, if you have some CSS rules that are using `!important` to set the display of `displayElementOrc1` and you still want to override them from JavaScript, you will need to use CSS classes instead.</p><p></p><p>For instance:</p><p></p><p>```css</p><p>/* Add this in your CSS */</p><p>.display-block-important {</p><p> display: block !important;</p><p>}</p><p></p><p>.display-none-important {</p><p> display: none !important;</p><p>}</p><p>```</p><p></p><p>And your JavaScript will be:</p><p></p><p>```javascript</p><p>const selectElementOrc1 = document.getElementById('meta_orcapplicable');</p><p>const displayElementOrc1 = document.getElementById('new_orcincluded');</p><p></p><p>selectElementOrc1.onchange = function() {</p><p> if (selectElementOrc1.value === 'Applicable') {</p><p> displayElementOrc1.classList.remove('display-none-important');</p><p> displayElementOrc1.classList.add('display-block-important');</p><p> } else {</p><p> displayElementOrc1.classList.remove('display-block-important');</p><p> displayElementOrc1.classList.add('display-none-important');</p><p> }</p><p>};</p><p>```</p><p></p><p>This will effectively override any existing CSS rules with the `!important` declaration.</p></blockquote><p></p>
[QUOTE="ryangate2, post: 28972633, member: 579789"] The issue with your code is the use of `!important` within JavaScript to change CSS styles. The `!important` rule is a part of CSS and it's not supposed to be used with JavaScript in this way. It has no effect in JavaScript and can cause your code not to work as expected. Here's the correct code: ```javascript const selectElementOrc1 = document.getElementById('meta_orcapplicable'); const displayElementOrc1 = document.getElementById('new_orcincluded'); selectElementOrc1.onchange = function() { if (selectElementOrc1.value === 'Applicable') { displayElementOrc1.style.display = 'block'; } else { displayElementOrc1.style.display = 'none'; } }; ``` This will show and hide your `displayElementOrc1` based on the value of `selectElementOrc1`. However, if you have some CSS rules that are using `!important` to set the display of `displayElementOrc1` and you still want to override them from JavaScript, you will need to use CSS classes instead. For instance: ```css /* Add this in your CSS */ .display-block-important { display: block !important; } .display-none-important { display: none !important; } ``` And your JavaScript will be: ```javascript const selectElementOrc1 = document.getElementById('meta_orcapplicable'); const displayElementOrc1 = document.getElementById('new_orcincluded'); selectElementOrc1.onchange = function() { if (selectElementOrc1.value === 'Applicable') { displayElementOrc1.classList.remove('display-none-important'); displayElementOrc1.classList.add('display-block-important'); } else { displayElementOrc1.classList.remove('display-block-important'); displayElementOrc1.classList.add('display-none-important'); } }; ``` This will effectively override any existing CSS rules with the `!important` declaration. [/QUOTE]
Insert quotes…
Verification
Awruddata maasa keeyada?
Post reply
Top
Bottom