G
G
Good Samaritan2018-01-30 14:05:33
JavaScript
Good Samaritan, 2018-01-30 14:05:33

How to access the a tag inside the table tag with the class class1?

How to replace the href value of a link inside a table with the class class1 ?
Tried so it does $(".class1").children("a").href="google.com";n't work

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hakkol, 2018-01-30
@djamali

$('table.class1 a').attr('href', 'https://toster.ru/')

I
Ivan Ivanov, 2018-01-30
@ZZiliST

if you don't use Jqury then you can do it like this

var element = document.querySelector('.class1 > a');
element.attr('href', 'https://toster.ru/');

I also want to note that there is still document.querySelectorAll . Its difference is that the line
var elements = document.querySelector('ul > li'); // вернёт массив в котором будут все li вложенные в тег ul

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question