JavaScript: Get anchor from URL JavaScript: Get Anker von URL
Posted on 10. Gesendet am 10. Jun, 2009 by Dragos in Apps , Coding , JavaScript & Ajax , PHP Juni 2009 von Dragos in Apps, Coding, JavaScript und Ajax, PHP
To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: Um den Anker aus einer URL zu erhalten (dies ist der Text nach dem Zeichen #) in JavaScript können Sie den folgenden Code verwenden:
var url='http://iwebdevel.com/some-post#comment-1'; //if you need to take the current url of the window use: var url=window.location; var url = 'http://iwebdevel.com/some-post # comment-1'; / /, wenn Sie brauchen, um die aktuelle URL des Fensters anzuwenden: var url = window.location; var anchor=url.hash; //anchor with the # character var anchor = url.hash; / / Anker mit dem Zeichen # var anchor2=url.hash.substring(1); //anchor without the # character var anchor2 = url.hash.substring (1); / / Anker, ohne das Zeichen #
If you're iterating through the links in a page with JQuery, and $(this) defines a single link, then to find the anchor of this object you'd need to use the following code: Wenn Sie Iteration sind durch die Links auf einer Seite mit JQuery und $ (this) definiert einen einzigen Link, dann auf den Anker des Objekts, das Sie müssten Sie den folgenden Code verwenden zu finden:
var anchor=$(this).attr("hash"); var anchor = $ (this). attr ( "Hash"); Related posts: In Verbindung stehende Pfosten:
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Wie in den Index zu erhalten (Position innerhalb einer Gruppe) eines Objekts mit jQuery?
- Javascript: How to validate email address with JavaScript? Javascript: Wie für die Validierung der E-Mail-Adresse mit JavaScript?
- JavaScript: Send function as a parameter to another function (callbacks) JavaScript: Send-Funktion als Parameter an eine andere Funktion (Rückrufe)
- JavaScript: What if jQuery animation doesn't fire/start? JavaScript: Was passiert, wenn jQuery Animation nicht Feuer / start?
- JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Wo finde ich alle Eigenschaften für alle HTML-Elemente?












































