0

I tried the following :

$('div.tp-bullet').attr('style','opacity:.4'); and

$('.tp-bullet').attr('style','opacity:.4');

but it did not work.

enter image description here

What am I missing ?

DinoMyte
  • 8,737
  • 1
  • 19
  • 26
angel
  • 4,474
  • 12
  • 57
  • 89

1 Answers1

0

Try use .css function to change the style like following :

$('div.tp-bullet').css('opacity','.4');
Norlihazmey Ghazali
  • 9,000
  • 1
  • 23
  • 40
  • even $('div.tp-bullet').attr('style','opacity:.4'); would work , it's just that it is not an optimal way to do it as it would override any existing style attribute. – DinoMyte Feb 23 '16 at 23:22
  • are you wrapping the code under $(document).ready if the dom is being loaded after script ? – DinoMyte Feb 23 '16 at 23:24
  • @DinoMyte ya i know that, why not giving him an alternative to try it out. Anyway no luck – Norlihazmey Ghazali Feb 23 '16 at 23:25
  • yes I am but this is not so simple as you show me, because I am using other script, (for one slider).this change some thing i dont use $ I use tpj(document) (what crazy). tpj(document).ready(funcion(){alert("hello");}); works – angel Feb 23 '16 at 23:27
  • So, you said that you have another version of jquery loaded as you're using naming conflix – Norlihazmey Ghazali Feb 23 '16 at 23:29
  • is there some way for get same result using javascript pure? – angel Feb 23 '16 at 23:30
  • @angel of course `document.querySelector("div.tp-bullet").style.opacity = '.4'` – Norlihazmey Ghazali Feb 23 '16 at 23:33
  • not working, but may be the problem is the style to opacity to 1 is being set after my code setting to .4 ( I am using the $(document).ready()) as I told this is tpj(document).ready(); – angel Feb 23 '16 at 23:38
  • Yes, there is something that intercept your code, do you have any async event used related to this code? – Norlihazmey Ghazali Feb 23 '16 at 23:44
  • is there some way for something similar to when.cssclass exist? or easier when div with class tp-bullet exist then execute this code...?? – angel Feb 23 '16 at 23:47
  • I have tried this one http://stackoverflow.com/a/5783355/586687 and I got "No exist" – angel Feb 23 '16 at 23:51
  • also make sure no rule in css for opacity that is `!important` – charlietfl Feb 24 '16 at 00:01