B
B
Bernard Krapivin2016-07-13 00:25:31
JavaScript
Bernard Krapivin, 2016-07-13 00:25:31

How to make js return href inside id?

Here is a piece of code, how to refer to href? you need to find it and replace it with js methods.
Please, help!
Tried GetElementById - doesn't help!
Example:

<li id="l_pr" class="">
  <a href="/id200986" onclick="return nav.go(this, event, {noback: true, params: {_ref: 'left_nav'}});" class="left_row">
</li>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dvorak, 2016-07-13
@Bobrodon

<a href='url' id='myId'>link</a>

var el = document.querySelector('#myId');
var href = el.getAttribute('href'); //получить href вашей ссылки
el.setAttribute('href', 'newurl'); //установить новый href

https://learn.javascript.ru/attributes-and-custom-... - more details

B
Bernard Krapivin, 2016-07-13
@Bobrodon

An example is here:

<li id="l_pr" class="">
  <a href="/id20026986" onclick="return nav.go(this, event, {noback: true, params: {_ref: 'left_nav'}});" class="left_row">
</li>

In this case, it returns null if you do as you suggested...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question