Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JS] jQuery Zaznaczenie wybranego zdjęcia
tomeknh
post
Post #1





Grupa: Zarejestrowani
Postów: 90
Pomógł: 0
Dołączył: 2.12.2007

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


Witam,

Mam div z zdjęciami:
  1. <div id="thumbs">
  2. <img src="foto/>
  3. <img src="foto/>
  4. <img src="foto/>
  5. <img src="foto/>
  6. </div>


Oraz kod jQuery

  1. $(document).ready(function() {
  2.  
  3. $("#thumbs img").click(function() {
  4. $(this).css("border", "1px solid red");
  5. });
  6.  
  7. }
  8. );


Po kliknięciu w dany obrazek robi się w okół niego czerwona ramka. Jak zrobić żeby klikając w nowy obrazek ramka z poprzedniego znikała?(IMG:style_emoticons/default/questionmark.gif) (IMG:style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tomeknh
post
Post #2





Grupa: Zarejestrowani
Postów: 90
Pomógł: 0
Dołączył: 2.12.2007

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


Niestety nie działa...popatrz:


  1. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  2. <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>
  3. <style type="text/css">
  4. img {
  5. border:0;
  6. }
  7. <script type="text/javascript">
  8. $(document).ready(function() {
  9. if( 1 ){
  10. $("#thumbs img").click(function() {
  11. $(this).parent().children('img').css("border", "0");
  12. $(this).css("border", "1px solid red");
  13. });
  14. }else{
  15. var imgs = $("#thumbs img");
  16. imgs.click(function() {
  17. $(imgs).css('border', 0).filter(this).css("border", "1px solid red");
  18. });
  19. }
  20. });
  21.  
  22.  
  23. </head>
  24.  
  25. <div style="width:880px;height:665px;margin:0 auto;text-align:left;" id="thumbs">
  26. <div>
  27. <a href="java script:void(0);" onclick="show('bz57l6hp.jpg', 960, 1)">
  28. <img src="s_0u2mu5pn.jpg" alt="" style="padding-right:8px;position:relative;top:0px;">
  29. </a>
  30.  
  31. <a href="java script:void(0);" onclick="show('bz57l6hp.jpg', 960, 2)">
  32. <img src="s_zzz5q6n3.jpg" alt="" style="padding-right:8px;position:relative;top:0px;">
  33. </a>
  34.  
  35. <a href="java script:void(0);" onclick="show('bz57l6hp.jpg', 1024, 3)">
  36. <img src="s_49bqgdda.jpg" alt="" style="padding-right:8px;position:relative;top:0px;">
  37. </a>
  38.  
  39. <a href="java script:void(0);" onclick="show('bz57l6hp.gif', 1024, 4)">
  40. <img src="s_q1gjczlh.gif" alt="" style="padding-right:8px;position:relative;top:0px;">
  41. </a>
  42.  
  43. <img src="files/img/spacer.gif" style="height:60px;width:278px;">
  44.  
  45. <a href="java script:void(0);" onclick="show('bz57l6hp.jpg', 1024, 5)">
  46. <img src="s_feqg5ngk.jpg" alt="" style="padding-right:8px;position:relative;top:0px;">
  47. </a>
  48.  
  49. <a href="java script:void(0);" onclick="show('bz57l6hp.jpg', 500, 6)">
  50. <img src="s_up2ygwan.jpg" alt="" style="padding-right:8px;position:relative;top:0px;">
  51. </a>
  52.  
  53. <a href="java script:void(0);" onclick="show('bz57l6hp.jpg', 1024, 7)">
  54. <img src="s_bz57l6hp.jpg" alt="" style="padding-right:8px;position:relative;top:0px;">
  55. </a>
  56.  
  57. <a href="java script:void(0);" onclick="show('eyx8hgel.jpg', 1024, 8)">
  58. <img src="s_eyx8hgel.jpg" alt="" style="padding-right:8px;position:relative;top:0px;">
  59. </a>
  60. </div>
  61. </div>
  62.  
  63.  
  64. </body></html>
  65.  


Ten post edytował tomeknh 6.08.2010, 23:57:49
Go to the top of the page
+Quote Post

Posty w temacie


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: 15.10.2025 - 15:58