For a project I need to make a sort of constructor to change some element in a page:
I have for example:
var element = ".h-event img";
var match = "eq(0)";
var type = "img";
var value = "breakfast.png";
Allowing me to construct:
$(element).attr('src', value);
With this code:
if(type=='img') {
$(element).attr('src', value);
}
The problem I have actually, is to use the eq() selector in jQuery by using by match variable.
How can I do that ?
This is what I already tried without success:
var match = (match=='') ? '': '.'+match+'.';
if(type=='img') {
$(element)match.attr('src', item.value);
}