Expanding all collapsible sections on a web page
I am interested in finding out if there is a way to expand all the collapsible sections on a webpage simultaneously. A relevant section on the webpage I am looking at looks like this:
<tr>
<td></td>
<td style="..;">
<div style="..">
<span id=".." style="display:inline;"><br />
<div style="display:inline"> ...
</div>
</span>
<span id="toHide1234" style="display:none;"><br />
<div style="display:inline">
<p>.....</p>
</div>
</span>
<a id="expcoll1234" href="JavaScript:expandcollapse('expcoll1234',1234)">
expand
</a>
</div>
</td>
</tr>
As seen above, by clicking on expand
link, this section would expand. Trouble is, there are hundreds of such expand
links on the webpage I am interested in, and there are many such web pages I want to do this for.
Any thoughts on this would be much appreciated. I need a really simple way to do this, as I am not very well versed with web programming. Just know very elementary HTML.
javascript html css webpage
add a comment |
I am interested in finding out if there is a way to expand all the collapsible sections on a webpage simultaneously. A relevant section on the webpage I am looking at looks like this:
<tr>
<td></td>
<td style="..;">
<div style="..">
<span id=".." style="display:inline;"><br />
<div style="display:inline"> ...
</div>
</span>
<span id="toHide1234" style="display:none;"><br />
<div style="display:inline">
<p>.....</p>
</div>
</span>
<a id="expcoll1234" href="JavaScript:expandcollapse('expcoll1234',1234)">
expand
</a>
</div>
</td>
</tr>
As seen above, by clicking on expand
link, this section would expand. Trouble is, there are hundreds of such expand
links on the webpage I am interested in, and there are many such web pages I want to do this for.
Any thoughts on this would be much appreciated. I need a really simple way to do this, as I am not very well versed with web programming. Just know very elementary HTML.
javascript html css webpage
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
– CBroe
Jul 4 at 13:19
1
@CBroe You posted a comment earlier that I could simply 'disable the style elements' on the webpage. I notice that you have deleted your comment. Actually, I did just that and it solved my problem. Since this is exactly the kind of simple solution I was looking for, I would request that if you could post your deleted comment as an answer, I will accept it. PS: I used superuser.com/questions/447269/… as a reference and used uMatrix extension on Google Chrome to disable CSS.
– seeker
Jul 4 at 16:03
Sure, happy to :-)
– CBroe
Jul 4 at 17:14
add a comment |
I am interested in finding out if there is a way to expand all the collapsible sections on a webpage simultaneously. A relevant section on the webpage I am looking at looks like this:
<tr>
<td></td>
<td style="..;">
<div style="..">
<span id=".." style="display:inline;"><br />
<div style="display:inline"> ...
</div>
</span>
<span id="toHide1234" style="display:none;"><br />
<div style="display:inline">
<p>.....</p>
</div>
</span>
<a id="expcoll1234" href="JavaScript:expandcollapse('expcoll1234',1234)">
expand
</a>
</div>
</td>
</tr>
As seen above, by clicking on expand
link, this section would expand. Trouble is, there are hundreds of such expand
links on the webpage I am interested in, and there are many such web pages I want to do this for.
Any thoughts on this would be much appreciated. I need a really simple way to do this, as I am not very well versed with web programming. Just know very elementary HTML.
javascript html css webpage
I am interested in finding out if there is a way to expand all the collapsible sections on a webpage simultaneously. A relevant section on the webpage I am looking at looks like this:
<tr>
<td></td>
<td style="..;">
<div style="..">
<span id=".." style="display:inline;"><br />
<div style="display:inline"> ...
</div>
</span>
<span id="toHide1234" style="display:none;"><br />
<div style="display:inline">
<p>.....</p>
</div>
</span>
<a id="expcoll1234" href="JavaScript:expandcollapse('expcoll1234',1234)">
expand
</a>
</div>
</td>
</tr>
As seen above, by clicking on expand
link, this section would expand. Trouble is, there are hundreds of such expand
links on the webpage I am interested in, and there are many such web pages I want to do this for.
Any thoughts on this would be much appreciated. I need a really simple way to do this, as I am not very well versed with web programming. Just know very elementary HTML.
<tr>
<td></td>
<td style="..;">
<div style="..">
<span id=".." style="display:inline;"><br />
<div style="display:inline"> ...
</div>
</span>
<span id="toHide1234" style="display:none;"><br />
<div style="display:inline">
<p>.....</p>
</div>
</span>
<a id="expcoll1234" href="JavaScript:expandcollapse('expcoll1234',1234)">
expand
</a>
</div>
</td>
</tr>
<tr>
<td></td>
<td style="..;">
<div style="..">
<span id=".." style="display:inline;"><br />
<div style="display:inline"> ...
</div>
</span>
<span id="toHide1234" style="display:none;"><br />
<div style="display:inline">
<p>.....</p>
</div>
</span>
<a id="expcoll1234" href="JavaScript:expandcollapse('expcoll1234',1234)">
expand
</a>
</div>
</td>
</tr>
javascript html css webpage
javascript html css webpage
edited Jul 5 at 10:55
Ignacio Ara
1,5471927
1,5471927
asked Jul 4 at 13:07
seeker
32
32
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
– CBroe
Jul 4 at 13:19
1
@CBroe You posted a comment earlier that I could simply 'disable the style elements' on the webpage. I notice that you have deleted your comment. Actually, I did just that and it solved my problem. Since this is exactly the kind of simple solution I was looking for, I would request that if you could post your deleted comment as an answer, I will accept it. PS: I used superuser.com/questions/447269/… as a reference and used uMatrix extension on Google Chrome to disable CSS.
– seeker
Jul 4 at 16:03
Sure, happy to :-)
– CBroe
Jul 4 at 17:14
add a comment |
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
– CBroe
Jul 4 at 13:19
1
@CBroe You posted a comment earlier that I could simply 'disable the style elements' on the webpage. I notice that you have deleted your comment. Actually, I did just that and it solved my problem. Since this is exactly the kind of simple solution I was looking for, I would request that if you could post your deleted comment as an answer, I will accept it. PS: I used superuser.com/questions/447269/… as a reference and used uMatrix extension on Google Chrome to disable CSS.
– seeker
Jul 4 at 16:03
Sure, happy to :-)
– CBroe
Jul 4 at 17:14
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
– CBroe
Jul 4 at 13:19
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
– CBroe
Jul 4 at 13:19
1
1
@CBroe You posted a comment earlier that I could simply 'disable the style elements' on the webpage. I notice that you have deleted your comment. Actually, I did just that and it solved my problem. Since this is exactly the kind of simple solution I was looking for, I would request that if you could post your deleted comment as an answer, I will accept it. PS: I used superuser.com/questions/447269/… as a reference and used uMatrix extension on Google Chrome to disable CSS.
– seeker
Jul 4 at 16:03
@CBroe You posted a comment earlier that I could simply 'disable the style elements' on the webpage. I notice that you have deleted your comment. Actually, I did just that and it solved my problem. Since this is exactly the kind of simple solution I was looking for, I would request that if you could post your deleted comment as an answer, I will accept it. PS: I used superuser.com/questions/447269/… as a reference and used uMatrix extension on Google Chrome to disable CSS.
– seeker
Jul 4 at 16:03
Sure, happy to :-)
– CBroe
Jul 4 at 17:14
Sure, happy to :-)
– CBroe
Jul 4 at 17:14
add a comment |
4 Answers
4
active
oldest
votes
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
If just getting at the “raw data” present in the HTML is the objective here, then your best bet is probably to disable styling in your browser completely - that overrides inline stuff like style="display:none;"
as well, so that everything should be visible right from the start.
As you said in comments, https://superuser.com/questions/447269/is-there-any-way-to-view-a-webpage-without-styles-in-chrome led to uMatrix browser extension, so if that works for your purposes - perfect ;-)
Yes, I simply just used the uMatrix extension to disable all CSS on the web pages I was interested in, and that caused all the relevant sections of the web pages to expand all at once.
– seeker
Jul 4 at 18:57
add a comment |
Assuming all your hidden sections have ids of format "toHide" + some numbers
you can find all the <span>
elements on the page and filter them by id and change display
style:
Array.from(document.getElementsByTagName('span'))
.filter(span => span.id.startsWith('toHide'))
.forEach(span => { span.style.display = ''; });
add a comment |
You could use jQuery to do this.
First, you would probably want to give every div
that expands an “expand” class or something, as welll as a class like “collapsed” that sets the height of the element to 0 (or however you are collapsing the element.)
<div class=“expand collapsed …”>
…
</div>
<div class=“expand collapsed…”>
…
</div>
You can then select all those <div>
s simultaneously and remove the collapsed class like so:
$(‘.expand’).removeClass(‘collapsed’);
You can stick that line in a function and call the function on a button press by setting the button’s onClick
Attribute to the name of the function.
Another approach is to use a library like Bootstrap—Bootstrap has a lovely collapse mechanism.
add a comment |
I had the same issue where I wanted to expand all of the abstract sections on Arxiv automatically. Using the Chrome dev console I found this worked exactly like I wanted:
('.abstract-full').css('display','inline')
Since the "abstract-full" class had display: none.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51174478%2fexpanding-all-collapsible-sections-on-a-web-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
If just getting at the “raw data” present in the HTML is the objective here, then your best bet is probably to disable styling in your browser completely - that overrides inline stuff like style="display:none;"
as well, so that everything should be visible right from the start.
As you said in comments, https://superuser.com/questions/447269/is-there-any-way-to-view-a-webpage-without-styles-in-chrome led to uMatrix browser extension, so if that works for your purposes - perfect ;-)
Yes, I simply just used the uMatrix extension to disable all CSS on the web pages I was interested in, and that caused all the relevant sections of the web pages to expand all at once.
– seeker
Jul 4 at 18:57
add a comment |
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
If just getting at the “raw data” present in the HTML is the objective here, then your best bet is probably to disable styling in your browser completely - that overrides inline stuff like style="display:none;"
as well, so that everything should be visible right from the start.
As you said in comments, https://superuser.com/questions/447269/is-there-any-way-to-view-a-webpage-without-styles-in-chrome led to uMatrix browser extension, so if that works for your purposes - perfect ;-)
Yes, I simply just used the uMatrix extension to disable all CSS on the web pages I was interested in, and that caused all the relevant sections of the web pages to expand all at once.
– seeker
Jul 4 at 18:57
add a comment |
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
If just getting at the “raw data” present in the HTML is the objective here, then your best bet is probably to disable styling in your browser completely - that overrides inline stuff like style="display:none;"
as well, so that everything should be visible right from the start.
As you said in comments, https://superuser.com/questions/447269/is-there-any-way-to-view-a-webpage-without-styles-in-chrome led to uMatrix browser extension, so if that works for your purposes - perfect ;-)
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
If just getting at the “raw data” present in the HTML is the objective here, then your best bet is probably to disable styling in your browser completely - that overrides inline stuff like style="display:none;"
as well, so that everything should be visible right from the start.
As you said in comments, https://superuser.com/questions/447269/is-there-any-way-to-view-a-webpage-without-styles-in-chrome led to uMatrix browser extension, so if that works for your purposes - perfect ;-)
answered Jul 4 at 17:14
CBroe
71.1k966111
71.1k966111
Yes, I simply just used the uMatrix extension to disable all CSS on the web pages I was interested in, and that caused all the relevant sections of the web pages to expand all at once.
– seeker
Jul 4 at 18:57
add a comment |
Yes, I simply just used the uMatrix extension to disable all CSS on the web pages I was interested in, and that caused all the relevant sections of the web pages to expand all at once.
– seeker
Jul 4 at 18:57
Yes, I simply just used the uMatrix extension to disable all CSS on the web pages I was interested in, and that caused all the relevant sections of the web pages to expand all at once.
– seeker
Jul 4 at 18:57
Yes, I simply just used the uMatrix extension to disable all CSS on the web pages I was interested in, and that caused all the relevant sections of the web pages to expand all at once.
– seeker
Jul 4 at 18:57
add a comment |
Assuming all your hidden sections have ids of format "toHide" + some numbers
you can find all the <span>
elements on the page and filter them by id and change display
style:
Array.from(document.getElementsByTagName('span'))
.filter(span => span.id.startsWith('toHide'))
.forEach(span => { span.style.display = ''; });
add a comment |
Assuming all your hidden sections have ids of format "toHide" + some numbers
you can find all the <span>
elements on the page and filter them by id and change display
style:
Array.from(document.getElementsByTagName('span'))
.filter(span => span.id.startsWith('toHide'))
.forEach(span => { span.style.display = ''; });
add a comment |
Assuming all your hidden sections have ids of format "toHide" + some numbers
you can find all the <span>
elements on the page and filter them by id and change display
style:
Array.from(document.getElementsByTagName('span'))
.filter(span => span.id.startsWith('toHide'))
.forEach(span => { span.style.display = ''; });
Assuming all your hidden sections have ids of format "toHide" + some numbers
you can find all the <span>
elements on the page and filter them by id and change display
style:
Array.from(document.getElementsByTagName('span'))
.filter(span => span.id.startsWith('toHide'))
.forEach(span => { span.style.display = ''; });
answered Jul 4 at 13:21
jaboja
1,2181830
1,2181830
add a comment |
add a comment |
You could use jQuery to do this.
First, you would probably want to give every div
that expands an “expand” class or something, as welll as a class like “collapsed” that sets the height of the element to 0 (or however you are collapsing the element.)
<div class=“expand collapsed …”>
…
</div>
<div class=“expand collapsed…”>
…
</div>
You can then select all those <div>
s simultaneously and remove the collapsed class like so:
$(‘.expand’).removeClass(‘collapsed’);
You can stick that line in a function and call the function on a button press by setting the button’s onClick
Attribute to the name of the function.
Another approach is to use a library like Bootstrap—Bootstrap has a lovely collapse mechanism.
add a comment |
You could use jQuery to do this.
First, you would probably want to give every div
that expands an “expand” class or something, as welll as a class like “collapsed” that sets the height of the element to 0 (or however you are collapsing the element.)
<div class=“expand collapsed …”>
…
</div>
<div class=“expand collapsed…”>
…
</div>
You can then select all those <div>
s simultaneously and remove the collapsed class like so:
$(‘.expand’).removeClass(‘collapsed’);
You can stick that line in a function and call the function on a button press by setting the button’s onClick
Attribute to the name of the function.
Another approach is to use a library like Bootstrap—Bootstrap has a lovely collapse mechanism.
add a comment |
You could use jQuery to do this.
First, you would probably want to give every div
that expands an “expand” class or something, as welll as a class like “collapsed” that sets the height of the element to 0 (or however you are collapsing the element.)
<div class=“expand collapsed …”>
…
</div>
<div class=“expand collapsed…”>
…
</div>
You can then select all those <div>
s simultaneously and remove the collapsed class like so:
$(‘.expand’).removeClass(‘collapsed’);
You can stick that line in a function and call the function on a button press by setting the button’s onClick
Attribute to the name of the function.
Another approach is to use a library like Bootstrap—Bootstrap has a lovely collapse mechanism.
You could use jQuery to do this.
First, you would probably want to give every div
that expands an “expand” class or something, as welll as a class like “collapsed” that sets the height of the element to 0 (or however you are collapsing the element.)
<div class=“expand collapsed …”>
…
</div>
<div class=“expand collapsed…”>
…
</div>
You can then select all those <div>
s simultaneously and remove the collapsed class like so:
$(‘.expand’).removeClass(‘collapsed’);
You can stick that line in a function and call the function on a button press by setting the button’s onClick
Attribute to the name of the function.
Another approach is to use a library like Bootstrap—Bootstrap has a lovely collapse mechanism.
answered Jul 4 at 13:28
Ashton Wiersdorf
567417
567417
add a comment |
add a comment |
I had the same issue where I wanted to expand all of the abstract sections on Arxiv automatically. Using the Chrome dev console I found this worked exactly like I wanted:
('.abstract-full').css('display','inline')
Since the "abstract-full" class had display: none.
add a comment |
I had the same issue where I wanted to expand all of the abstract sections on Arxiv automatically. Using the Chrome dev console I found this worked exactly like I wanted:
('.abstract-full').css('display','inline')
Since the "abstract-full" class had display: none.
add a comment |
I had the same issue where I wanted to expand all of the abstract sections on Arxiv automatically. Using the Chrome dev console I found this worked exactly like I wanted:
('.abstract-full').css('display','inline')
Since the "abstract-full" class had display: none.
I had the same issue where I wanted to expand all of the abstract sections on Arxiv automatically. Using the Chrome dev console I found this worked exactly like I wanted:
('.abstract-full').css('display','inline')
Since the "abstract-full" class had display: none.
answered Nov 21 at 2:26
Fosa
12610
12610
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51174478%2fexpanding-all-collapsible-sections-on-a-web-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
So you want to use this on a website that isn’t under your control? Then you are limited in your possibilities to get your own JavaScript code inserted into that in the first place. It could perhaps work from the browser console or a “bookmarklet”, if the target site does not prevent that via CSP.
– CBroe
Jul 4 at 13:19
1
@CBroe You posted a comment earlier that I could simply 'disable the style elements' on the webpage. I notice that you have deleted your comment. Actually, I did just that and it solved my problem. Since this is exactly the kind of simple solution I was looking for, I would request that if you could post your deleted comment as an answer, I will accept it. PS: I used superuser.com/questions/447269/… as a reference and used uMatrix extension on Google Chrome to disable CSS.
– seeker
Jul 4 at 16:03
Sure, happy to :-)
– CBroe
Jul 4 at 17:14