• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Anyone knows what is wrong with that Javascript? #Dreamweaver #Javascript #iframe

Community Beginner ,
Jun 22, 2020 Jun 22, 2020

Copy link to clipboard

Copied

Changeing CSS of certain element based on certain title of other element with Javascript... to change style works already, but not yet based on title selector...

if (getElemtById(blockrandom).title == ("sophia-lilith-implant")) 

{var style = document.createElement('style');
style.appendChild(document.createTextNode('.contentpane {padding-bottom: 260% !important}'));
document.body.appendChild(style);}

else {alert("hello");}


Thanks in advance

TOPICS
How to

Views

252

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 22, 2020 Jun 22, 2020

Copy link to clipboard

Copied

Is there maybe a way to do it in pure CSS? I already tried:

.contentpane iframe [title='sophia-lilith-implant'] {
.contentpane {padding-bottom: 260%;}
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2020 Jun 22, 2020

Copy link to clipboard

Copied

LATEST

Try including an 'additional class' in your css stylesheet:

 

.additionalStyles {
padding-bottom: 260%;
}

 

Then use the below javascript to apply the class IF 'blockrandom' title === "sophia-lilith-implant":

 

<script>

const contentpane = document.querySelector('.contentpane');
if(document.getElementById('blockrandom').title === "sophia-lilith-implant") {
contentpane.classList.add('additionalStyles')
}

</script>

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 22, 2020 Jun 22, 2020

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2020 Jun 22, 2020

Copy link to clipboard

Copied

Not sure what you are trying to do but the code you posted is incorrect. First line should be:

 

if(document.getElementById('blockrandom').title === "sophia-lilith-implant") {

 

See if that makes a difference.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines