- Screen name: pxsteiner
pxsteiner's Profile
31 Posts
20 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- 25-Jul-2017 03:40 PM
- Forum: Using jQuery
How can I insert the current timestamp in format DD.MM.YYYY HH:MM:SS ?
Peter
- 01-Jul-2017 08:45 AM
- Forum: Using jQuery
Assume I have a web page with multiple instances of elements that have (among others) the following CSS definition:
- #........... { .....
- border: 1px dashed #ddd;
- ..... }
How can address all these elements with jQuery?
The following does not work:
$("[border: 1px dashed #ddd]")
How else does that work?
Peter
Assume I have a html structure like
- <div class="aaa">
- ....
- <a href="http://.......>linktext</a>
- ...
- <a href="http://.......>other linktext</a>
- ...
- </div>
Now I want ot remove (only inside the div[aaa] element) all wrapping <a> elements which contain a href= attribute but leave the inner content of the <a> elements´. When I code something like
$("div.aaa).$("a[href]").unwrap();
then the wrapping div.aaa is removed and not the <a> s
How can I achieve this (otherwise)?
Peter
Assume I have a html code like:
- <div class=someclass"> ....</div>
How do I insert a simple text (=without a wrapping element) after the <div> element?
- $("sometext").text().insertAfter($(".someclass"));
does not work.
Assume I have a source code like
<div ...... class="aaa bbb" ....>....</div>
How can I replace the class value by another one resp. more precisely how can I delete the "bbb" class?
The final code should look like:
<div ...... class="aaa" ....>....</div>
Is there a way to reload the current web page every 20 seconds with jQuery?
Peter
Assume the following source structure:
- <div>
- aaa
- <br>
- bbb
- <b>mytitle1234</b>
- ccc
- <br>
- <h3> h3headline</h3>
- ddd
- <br>
- eee
- <br>
- </div>
- lineoutside
Now I want (simplified) to change the font size of all text which follows "<b>mytitle1234</b>" but only on the same hierarchy level.
If I code
- $("b:contains('mytitle1234')").nextAll()......
then the fontsize of only the <h3> element will be changed.
But I want to change "ccc" "ddd" "eee" as well (but not "lineoutside").
How can I achieve this?
Peter
- 24-Apr-2017 01:37 PM
- Forum: Using jQuery
Assume I have a jQuery command like:
$('div[myattr="foobar"]').parent().remove();
How can I wrap (?) this command so that:
- all found core elements are listed (at the console)?
- all found parent() elements are listed (at the console)?
- the result after remove() is shown at the console ()?
Peter
Assume the following code
- <a class="foobar" ....>.....</a>
- <br>
How do I remove the <br> tag following (all) <a> elements with class="foobar"?
The following does not work:
$("a.foobar").next().remove();
Why not?
Peter
Assume I have a web page which contains multiple elements similar to
- <span style="font-size: medium;">....</span>
How can I remove the "style=" attribute for all the elements?
The element <span> itself should still persist
Peter
Assume I have a webpage with lots of lines similar to
- <tr> <td> </td> </tr>
The tags avove could be spread over multiple lines.
Between them could be zero, one or more whitespaces.
I want to get rid of them all.
Therefore I coded the following two jQuery statements:
- $("td").filter( function(){ return $(this).html().match(/^\s*$/) }).remove();
- $("tr").filter( function(){ return $(this).html().match(/^\s*$/) }).remove();
The first should remove all inner <td> </td> occurencies.
The last then all remaining (now empty) <tr> </tr> occurencies.
But this seems NOT to work.
Whats worng?
How can I achieve this otherwise?
Does \s really represent all whitespace?
Where is a list of all possible special chars in the match() statement?
Peter
At first a sample source code as snapshot:
https://abload.de/img/embeddedvideoddohu.png
As you can see there is an embedded video just below the top photo.
How can I hide/remove this video?
I tried so far:
- $("#player").closest("p").remove();
or
- $('iframe[src="https://www.youtube.com/embed/*"]').css("display", "none");
but none of them work.
Why not?
Peter
Lets start with a sample page:
http://www.thewindowsclub.com/winguard-pro-password-protect
I want to get rid of the two lines inside the article which start with "RECOMMENDED:"
Therefore I coded:
- $("RECOMMENDED:").closest("div").remove();
but this does not work.
The command was told me to delete (only) the next <div> element above a certain string (here: "RECOMMENDED:")
Whats wrong?
Peter
- 14-Jan-2017 03:36 AM
- Forum: Using jQuery
Assume we have the following html structure:
- <div class="aaa"><div ....>...
<div class="bbb">...</div>
</div></div>
<div class="foobar"><div ....>...
<div class="bbb">...</div>
</div></div>
Now I want to do the following:
- Search for all <div> elements with class="bbb"
- then (for each found element) go (one or more levels) upwards and search for a(nother) <div> element with class="foobar"
- If it exist then remove this <div> element with class=foobar. Otherwise do nothingIt the sample above only the second part should be removed.
How can I achieve this?
Peter
Assume I have the following HTML structure:
- <div class="aaa bbb">
- <a id="ccc8888" class="......." href="javascript://">
- <span class="ddd eee">click here</span>
- </a>
- </div>
- ....
- <div class="aaa bbb">
- <a id="ccc7456" class="......." href="javascript://">
- <span class="ddd eee">click here</span>
- </a>
- </div>
When the users clicks manually with the mouse on "click here" text then something is expanded on webpage.
How do I simulate a click on ALL/EACH (!) such items on a webpage?
The items differ only in the id number (in the first element above = 8888).
I need something like a wildcard mechanism.
The following solutions do not work:
$('a#id="ccc*"').click();
or
$('a[id="ccc*"]').click();
or
$('id="ccc*"').click();
How else does that work?
Peter
Assume on a web page there are text strings with the pattern "aaa bbb ccc" (without double quotes).
I want to replace them by a blank or even with nothing (=empty string).
Until now I used the following javascript commands to accomplish this:
var content=document.body.innerHTML;
newContent=content.replace(/aaa bbb ccc/g,' ');
document.body.innerHTML=newContent;Is there a better way with jQuery to do this?
Is there a way to restrict the replacement to only <ul>......</ul> elements resp. their inner content?
Thank you
Peter
Assume I have the following HTML source code
<div class="foobar" ....>...
<picture ...>....
<img ....> ...</img>
....</picture>
...</div>
How can I extract the <img> element and move it one level up just before (resp. after) the <picture> element?
This procedure should be done for all <img> below the enclosing <div class="foobar"> but not for the <img>s outside.
Thank you
Peter
- Assume I have the following source structure:
- <div id="aaa-bbb-ccc-3263262623627" ....> .....</div>
- < div id="aaa-bbb-ccc-4568458573737" ....> .....</div>
- < div id="aaa-bbb-ccc-56747" ....> .....</div>
- < div id="aaa-bbb-ccc-8679865998080600" ....> .....</div>
How can I reference all elements in ONE jQuery statement?
Actually I need something like a wildcard to write
$('div[id="aaa-bbb-ccc-*"]')
But this does not work.
How do I have to re-write it?
It would be even better to have something more advanced, regular expression-like which let me limit the wildcard in more detail. So I can write instead of "*" the filter "one or more digits".
Peter- 16-Oct-2016 12:26 AM
- Forum: Using jQuery
The problem seems to be simple. Assume we have a definition like
<p class="aaaclass bbbclass">........</p>
Now I want to remove in all elements <p ...> on the web page which have an assigned class "aaaclass"
exactly this class so that afterwards the code look like:
<p class="bbbclass">........</p>
How does that work?
Next question: How do I have to modify your suggested jQuery statement if I want to remove BOTH or ALL classes (see above) so that afterwards the code looks like:
<p>........</p>
And last question:
How can I (independently from the class removal above) remove the corresponding CSS statements
.aaaclass { ,,,,,,, }
.bbbclass { ...... }
Thank you
Peter- 01-Oct-2016 04:09 AM
- Forum: Using jQuery
Assume I have a webpage with the following structure:
- <div class="foobar">
- ....
- <div class="blahblah"> ..... </div>
- sometext ....someotherelemens
- ...
- paste cut element here
- </div>
Now I want to cut the element with the class="blahblah" (including its inner content) from its original place
and paste it just before the closing </div> for the element <div class="foobar">
How can I do this with jQuery?
If necessary the operation can be split into two jQuery statements.
However a one-liner is preferred.
Thank you
Peter
- 21-Sep-2016 01:01 AM
- Forum: Using jQuery
Assume I select a certain element and want to assign NOT only ONE but MULTIPLE css statements.
How do I do this?
For ONE .css() this works fine:
$(......).css({'background-color' : 'red'});
But what if I want to assign a new font-size as well?
Do I really have to write two separate lines?
I would appreciate if I could group them together into one line similar to
$(......).css({'background-color' : 'red', 'font-size' : '11px !important';});
but this does not work.
By the way: Is the !important statement necessary if it is applied through jQuery and an existing rule
should be overwritten?
Peter
Assuem I have somewhere on a web page the following text: "aa bb cc".
Now I want to replace this text by nothing (or one blank).
Then the following does NOT work:
$("aa bb cc").text('');
Why?
- 10-Sep-2016 01:57 AM
- Forum: Using jQuery
Assume we have the following web page source code- ...
<p>
....
<p ....>
<span class="aaa">
<a class="bbb">....</a>
...sampletext
</span>
</p>
</p>
How can I address/refer only (!) to the next <p> element above an inner leement which is defined by class=bbb?
If one can refer to a simple string like "sampletext" then one could write successfully:
- $("p:contains('sampletext')").eq(($("p:contains('sampletext')").length) - 1).css("display", "none");
But what if I do not have identifying string like "sampletext" but only an element with unique class=bbb?
The following does not work:
- $("p:contains(.bbb)").eq(($("p:contains(.bbb)").length) - 1).css("display", "none");
How do I have to rewrite this statement?
Does your solution work with unique IDs as well?
Peter
Have a look at the following (german) webpage:
https://www.wikifolio.com/de/de/wikifolio/esi893
When you goto section "Handelsidee" and click on the minus sign right of it you can collapse the section.
See the following code snapshot:
http://www.picfront.org/d/9qjt
I want to automate this when I visit the web page.
When I code therefore:
$('div.accordion-header.collapsed[href=#collapseOne]').click();
then this collapse action does not work.
Why?
Peter
Assume I want to find and hide the next "<p>" element above each "<iframe>" element.
Example:
- <p>
- sometext
- ...<p>
- somesubtext
- <iframe width="400" ....> ...</iframe>
- </p>
- other text ....
- <p>
When the target search filter is not an element but a text I could write:
$("p:contains('somesubtext')").eq(($("p:contains('somesubtext')").length) - 1).css("display", "none");
This is working fine.
However what if I want to search for an element <iframe> (possibly with an attribute filter).
then the following does NOT work:
$("p:contains('<iframe[width="400"]>')").eq(($("p:contains('<iframe[width="400"]>')").length) - 1).css("display", "none");
How else can I do this?
Peter
- «Prev
- Next »
Moderate user : pxsteiner
© 2013 jQuery Foundation
Sponsored by
and others.


