🔒 Closed Javascript asking

Status
Not open for further replies.

loktoy

Established
tanong ko lang po dito sa banda na to

if (dots.style.display === "none") {
dots.style.display = "inline";
btnText.innerHTML = "Read more";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";

yun style po nakalagay ay yan po ba yun style na internal..
kung tama po yun hula ko po
pano nman po kung galing external na sarili files po ng css


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#more {display: none;}
</style>
</head>
<body>

<h2>Read More Read Less Button</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas vitae scel<span id="dots">...</span><span id="more">erisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta.</span></p>
<button onclick="myFunction()" id="myBtn">Read more</button>

<script>
function myFunction() {
var dots = document.getElementById("dots");
var moreText = document.getElementById("more");
var btnText = document.getElementById("myBtn");

if (dots.style.display === "none") {
dots.style.display = "inline";
btnText.innerHTML = "Read more";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
}
}
</script>

</body>
</html>
 
No, the style in the JavaScript code is not an internal style. It is simply modifying the display property of the dots and moreText elements to either "none" or "inline" depending on their previous state.

If the CSS code for #more was located in an external CSS file, it would still work the same way as long as the file was linked correctly in the HTML document. The JavaScript code would still modify the display property of the elements the same way, regardless of whether the style was internal or external.
 
ganun pa rin. i link mo lang ng maayos sa head tag mo yung external css mo.
sir ask ko lang po kasi kapag minamanual ko yun java nag eerror
pero kapag copy paste lang ok nman
same lang din yun code as in tinatype ko lang nag eerror pero kapag copy paste hindi nman
 
sir ask ko lang po kasi kapag minamanual ko yun java nag eerror
pero kapag copy paste lang ok nman
same lang din yun code as in tinatype ko lang nag eerror pero kapag copy paste hindi nman
paanong nag eerror. may maipoprovide ka bang screenshot ng error(s)?
 
Status
Not open for further replies.

About this Thread

  • 4
    Replies
  • 443
    Views
  • 2
    Participants
Last reply from:
Misanthropy

Trending Topics

Online now

Members online
605
Guests online
1,167
Total visitors
1,772

Forum statistics

Threads
2,273,547
Posts
28,950,297
Members
1,235,813
Latest member
Dji
Back
Top