![]() |
How to delete and insert things using JS?
Hello everyone!
I'm using software on a site that only allows me to insert changes using a js file and a css file. Sadly, I'm not familiar with js. There is a snipit of code that I want to remove. There are 4 tabs below, I want to remove the first 3. How can I remove them using js? Code:
<ul class="ui-tabs-nav">Suppose I wanted to change the "tab4" text to something else? Thank you all for the help over the past few years :) |
Seeing the “ui-…” class names I suppose you are using jQuery, right? I’m gonna move the thread to the JS frameworks section.
Now, would you mind to share with us why you want to remove and change the items with JS rather than by just editing the HTML? In which context is this being used? |
Quote:
Code:
li = document.getElementsByClassName('ui-state-default'); |
Quote:
Hey Stephan, I cannot edit the HTML, because I do not have access to edit the HTML file. I can only edit it by appending a .js file and a .css file. |
one of the best ways to deal with things like lists is to iterate over them with the each method, which keeps an index that you can use to operate on elements according to their position:
Code:
$(".ui-tabs-nav li").each(function (idx) { |
Quote:
|
:confused:
Quote:
|
Quote:
I appreciate all the JS tips! I will be trying these out tonight :) |
why not simply hide it with css?
Code:
.ui-tabs-nav .ui-state-default { display: none; } |
Hello everyone, thanks for the help so far.
I decided instead of removing them, I will just rename them using the JS that felgall supplied (Thanks!). I have another question; For each tab, it has a description inside it. I want to change the words in the description, so delete it and then rewrite it. Could someone tell me how I would do that? And could you try to explain each line of code so I can try to apply it to more situations :) Code:
div id="tabs-1" class="row ui-tabs-panel ui-widget-content ui-corner-bottom"> |
Hey guys,
I played around with the JS and I got something that kind of works... It does what I want it to do, but on some other pages, it messes things up. I've got no idea why its doing that. Everything after the favicon line is messing up other pages. I tried doing one set of replacing vars at a time and each one works, but also makes slight changes to other pages. There don't seem to be any shared ID's or classes though. So I think it might just be a syntax problem or something.. Is there a problem with the way I wrote this? Code:
$(document).ready(function() { |
| All times are GMT +1. The time now is 01:36 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.