Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Zastąpienie konkretnego selektora w JQuery (IE), Nie działający selektor w IE
gregiolo
post
Post #1





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 1.02.2010
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Witam,
Jak zastąpić Waszym zdaniem selektor jquery, który nie działa pod IE 7 chociażby? :/

$("div[id^='bt']").

Pozdrawiam

Ten post edytował gregiolo 10.03.2010, 07:22:11
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 565
Pomógł: 6315
Dołączył: 27.12.2004




Pokaz lepiej swoj kod html i oraz pelen kod js.
jQuery dziala bez problemu pod IE w tym rownież ten selektor.
Go to the top of the page
+Quote Post
gregiolo
post
Post #3





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 1.02.2010
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Oto kod.
[JAVASCRIPT] pobierz, plaintext
  1. function ButtonsHover() {
  2.  
  3. $("div[id^='bt']").mouseover(function() {
  4. scroll = $(this).css("height");
  5. $(this).css("background-position","0 "+scroll);
  6. })
  7.  
  8. $("div[id^='bt']").mouseout(function() {
  9. $(this).css("background-position","0 0");
  10. })
  11. };
[JAVASCRIPT] pobierz, plaintext


Przy podmianie $("div[id^='bt']") na np. $("#test") kod działa poprawnie.

Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 565
Pomógł: 6315
Dołączył: 27.12.2004




czy ja piszę po chinsku?
Cytat
swoj kod html i oraz pelen kod js.
Go to the top of the page
+Quote Post
gregiolo
post
Post #5





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 1.02.2010
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


  1. <script src="js/jquery-latest.js" type="text/JavaScript"></script>
  2. <link href="test.css" media="all" type="text/css" rel="stylesheet">
  3. <script type="text/JavaScript">
  4. function ButtonsHover() {
  5.  
  6. $("div[id^='bt']").mouseover(function() {
  7. scroll = $(this).css("height");
  8. $(this).css("background-position","0 "+scroll);
  9. })
  10.  
  11. $("div[id^='bt']").mouseout(function() {
  12. $(this).css("background-position","0 0");
  13. })
  14. };
  15.  
  16. ButtonsHover();
  17. </script>
  18. </head>
  19. <div class="button" id="btUser0"></div>
  20. <div class="button" id="btUser1"></div>
  21. </body>
  22. </html>
  23.  


Ten post edytował gregiolo 10.03.2010, 10:00:00
Go to the top of the page
+Quote Post
nospor
post
Post #6





Grupa: Moderatorzy
Postów: 36 565
Pomógł: 6315
Dołączył: 27.12.2004




ButtonsHover(); powinienes wywolac dopiero po zaladowaniu calego DOM, czyli:
Kod
jQuery(function(){
ButtonsHover();
});


Poza tym stosowanie ^= jest malo optymalne. U ciebie mozna by to zastąpic:
$("div.button")
Go to the top of the page
+Quote Post
gregiolo
post
Post #7





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 1.02.2010
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Ok dzieki.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 10.06.2026 - 12:37