How can I hide an id from its contents in Javascript/jQuery? - javascript

I have a bunch of this videos on this website with this source:
<li id="vidLink-1498229769" class="videoContainer vidLink">
<a href="/p/watch/1498229769:GM1ryG4eoTA6sMZV9wtDEpocuehpzDni">
<span class="content-video-thumb-hover"></span>
<img src="http://lockerz.vo.llnwd.net/o35/Lockerz/14/593/MEVIO-EmoGirlTV-SavesTheDay-TH1.jpg" id="clThumb_1498229769" class="videoThumb">
</a>
Emo Girl TV - Saves the Day Interview
<span class="PTZ-status PTZ-awarded">PTZ have been awarded for watching this video.</span>
Is it possible to hide the entire id, the vidlink-*** part if the span class is that?
<span class="PTZ-status PTZ-awarded">PTZ have been awarded for watching this video.</span>
I want to hide the videos I've already seen in the site (with greasemonkey), but I have no idea how...

If you're trying to hide the entire vidLink if it contains a .PTZ-status, you can do it like this:
$('.vidLink:has(.PTZ-awarded)').hide();

Related

How to set location or name auto fill in trip advisor widget?

My problem is I have a lot of hotels lists on my website, but trip advisor widget only can get one. Any solution (example:script or what else) can use varible to set the location or name in widget automatically, it will auto search and display different hotel widget in the same code. Poor English hope your guys understand. Thank a lot.
<div id="TA_selfserveprop189" class="TA_selfserveprop">
<ul id="0DhvHbHb" class="TA_links wMTad7Z">
<li id="BkwXZV" class="yr3LWVW09h">
<a target="_blank" href="http://www.tripadvisor.com/"><img src="http://www.tripadvisor.com/img/cdsi/img2/branding/150_logo-11900-2.png" alt="TripAdvisor"/></a>
</li>
</ul>
<script src"http://www.jscache.com/wejs?wtype=selfserveprop&uniq=189&locationId=2701589&
lang=en_US&rating=true&nreviews=5&writereviewlink=true&popIdx=true&iswide=false&border=true&display_version=2"></script>
do u want to use auto complete to show a div like google search, you can use autocomplete addon of jquery.
I have implemented it many times, it is great for that purpose.
for reference use this example.http://www.tutorialspoint.com/jqueryui/jqueryui_autocomplete.htm
it also shows various example and documentation.
https://jqueryui.com/autocomplete/

Addthis: Display total shares

I would like to get the AddThis widget to display the total number of shares of an URL on Facebook, Twitter and Google+. Here comes my code:
<script src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
<div addthis:url="http://de.wikipedia.org/wiki/JavaScript" addthis:title="Wikipedia JavaScript page">
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_google_plusone"></a>
<a class="addthis_button_email"></a>
</div>
JSFIDDLE: http://jsfiddle.net/ez8ya0ov/
How do I achieve that the total count of shares on facebook, twitter and google+ get displayed in a bubble on the right side? I do NOT want the individual numbers of each social media service get displayed (in this example I want to get rid of the bubble with "7" next to the google+ icon). Anyone has an idea how to achieve that?

Changing anchor tag text while using PhoneGap and jQuery

As a preface, I am using PhoneGap. When I click on a Category Title, I have taken that title and set it in sessionStorage. Now, I want to set the "back" button of a new PhoneGap page (which displays some information contained in that category) to that Category Title. The HTML code is shown below. To be specific, I want to change the text of the "a" element within the "header" element.
I guess a part of my question is, does the fact that I am using PhoneGap change how I can access the anchor tag? I've been trying to set the back button text right after the Category has been selected/clicked on. I have tried multiple things like:
$("adviceBodyNavbarHeader a").text(sessionStorage.getItem("catTitle"));
but I can't quite get it working, and it is getting quite frustrating =/
<div data-role="view" id="adviceBody" data-title="Advice Body" data-show="GetAdviceBody" data-transition="slide">
<header data-role="header" id="adviceBodyNavbarHeader">
<div class="navHeader">
<a class="nav-button" data-view="adviceTitles" data-align="left">Back</a>
<span id="adviceTitle" class="navTitle"></span>
</div>
</header>
<ul id="advice-body" data-role="listview">
</ul>
</div>
Your selector is wrong. You try to select a html element called adviceBodyNavbarHeader.
What you want to do is this: $('#adviceBodyNavbarHeader').text(sessionStorage.getItem("catTitle"));
Hope it helps.
Edited my post due to late brain inactivity.

How to edit text for a link that does not have an ID using Javascript

I want to change the text of a link using javascript. The problem is this particular link does not have an id. I am unable to change the html, as this is a SharePoint page, and this particular link is created by a page layout, which I do not have access to. Using IE Developer Tools, I see that the HTML surrounding the link is this:
<span id="DeltaPlaceHolderPageTitleInTitleArea">
<span>
<a href="#ctl00_PlaceHolderPageTitleInTitleArea_ctl00_SkipLink">
<img width="0" height="0" style="border-width: 0px;" alt="Skip Navigation Links" src="" /></a>
<span>
<a title="State-Compliance" href="/sites/tax/Compliance/SitePages/State-Compliance.aspx">State-Compliance</a>
</span>
<a id="ctl00_PlaceHolderPageTitleInTitleArea_ctl00_SkipLink"></a>
</span>
The link I wish to change is the second one, the one with "State-Compliance" for the tooltip.
I looked at jQuery, and found I could use $('#DeltaPlaceHolderPageTitleInTitleArea').find("a").text("Test"); to change the text, but it changes the text of all three links. How can I change just the one? Do I need to iterate through the three, or is there an easier way of getting the link I wish to change?
Sorry if this is a stupid question, I'm a c# developer, and this is my first experience using javascript.
Let me know if you need more information.
Warren
Use .eq():
$('#DeltaPlaceHolderPageTitleInTitleArea').find("a").eq(1).text("Test");
jsFiddle example
How about this, using the attribute equals selector:
$('#DeltaPlaceHolderPageTitleInTitleArea a[title="State-Compliance"]')

How to extracts a links under multiple Span tags using selenium webdriver

I need to count and display the number of links available under different Span Tags.
In the following HTML code, I have two anchor links under Span 'Upcoming Event' and 4 links under 'Recent Free LIVE Webinars' section.
Please provide an Xpath to get these details.
<!-- language: html -->
<div class="widget widget_text">
<div class="widget-wrap">
<div class="textwidget">
<span style="color: #FF3300;font-size:14px">
<b>Upcoming Event </b>
</span>
<a href="http://www.itelearn.com/events/mobile-application-testing-
career">2nd July 2013:Your Career in Mobile Application Testing </a>
<a href="http://www.itelearn.com/live-training/qtp-11-live-
training#">19thJune 2013 : QTP Live Training</a>
<span style="color: #FF3300;font-size:14px">
<b>Recent Free LIVE Webinars</b>
</span>
<a href="http://www.itelearn.com/events/teachitelenter code hereearn-a-
mega-webinar">Teach#ITeLearn Initiative </a>
<a href="http://www.itelearn.com/events/how-to-be-a-software-security-
testing-expert">How to become a Software Security Testing Expert?</a>
<a href="http://www.itelearn.com/events/how-to-master-hp-qtp">How to
Master QTP?</a>
<a href="http://www.itelearn.com/events/how-to-master-selenium-video-
page">How to Master Selenium?
</a>
To me this would be the easiest method. Find all the spans on the page, then for each span find all of the anchor elements, print the length of that list and then iterate over the list to get the href value and print that too.
spans = driver.find_elements_by_tag_name("span")
for span in spans:
links = span.find_elements_by_tag_name("a")
print(str(links.length()));
for link in links:
print(link.getAttribute("href"));
Please try below XPATH to find element
//For 'Upcoming Event' span ..
XPATH = "//span//b[text()='Upcoming Event']//a"
//For 'Recent Free LIVE Webinars' span ...
XPATH="//span//b[text()='Recent Free LIVE Webinars']//a"

Categories

Resources