/    Sign up×
Community /Pin to ProfileBookmark

Removing text from a page using Javascript

Hi everyone,

Basically, I have a page that is pulls in various data elements which I don’t have access to edit, which also means I do not have access to edit the HTML.

What I do have access/ability to edit/create are stylesheets and javascript.

Here is the snip-it of code I’m looking to edit:

<td style=”width: 22em; font-size: .9em; color: #000000;”>
Progress: 0%
<br />
Registrations: 0
&nbsp;&nbsp;&nbsp;
Goal: 5000
</td>

What I don’t want displayed is ‘Registrations: 0’

Is there a javascript that can be created to find the words ‘Registration: 0’ and either remove it from the HTML or hide it with a css style such as display:none?

Any help would be much appreciated.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@daveyerwinNov 13.2015 — Hi everyone,

I do not have access to edit the HTML.

[/QUOTE]


How will you include

the JavaScript ?
Copy linkTweet thisAlerts:
@sierraauthorNov 13.2015 — It's very compartmentalized. Somewhat like a CMS. It has a block I can add Javascript and CSS. I can edit some of the HTML, but this particular piece is being brought in as a piece of session tag, so I want some but not all of this piece.
Copy linkTweet thisAlerts:
@daveyerwinNov 13.2015 — this particular piece is being brought in as a piece of session tag, so I want some but not all of this piece.[/QUOTE]

There is your solution,

where it is "brought in"

you can edit it before

it is applied to the

html.
Copy linkTweet thisAlerts:
@SempervivumNov 13.2015 — I encountered a similar task some days before. I'm quite shure that the words like 'Registration: 0' you want to delete are in the visible Text, not inside HTML tags? Then this can be done quite easily: Scan all text nodes as described here:

https://api.jquery.com/contents/

Wrap the text in span tags. This enables you to access the text e. g. by jQuery text() and modify it by e. g.:
ele.text(ele.text().replace('Registration: 0', ''));
Copy linkTweet thisAlerts:
@xelawhoNov 13.2015 — Will registrations only ever be zero? And will that text only ever be within td tags? Seems to me like you could refine your approach a little here.
Copy linkTweet thisAlerts:
@ahmadabbasNov 14.2015 — why you can do this ? beacuse for different reason different method is used
×

Success!

Help @sierra spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...