Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> zamiana spacji na myślniki, jak?
marcus755
post
Post #1





Grupa: Zarejestrowani
Postów: 158
Pomógł: 1
Dołączył: 6.12.2012

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


Jak zamienić we wszystkich div'ach z class="example" w attr id spacje na myślniki?

<div class="example" id="lorem ipsum">
<div class="example" id="dolor sit amet">
<div class="example" id="consectetur adipiscing elit">

wynik docelowy:

<div class="example" id="lorem-ipsum">
<div class="example" id="dolor-sit-amet">
<div class="example" id="consectetur-adipiscing-elit">

Ten post edytował marcus755 17.09.2015, 09:01:03
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Comandeer
post
Post #2





Grupa: Zarejestrowani
Postów: 1 268
Pomógł: 254
Dołączył: 11.06.2009
Skąd: Świętochłowice

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


Ale w sumie w JS wygląda to bardzo, bardzo podobnie (IMG:style_emoticons/default/wink.gif) Też trza pobrać elementy (document.querySelectorAll), zmieniasz atrybut (str.replace) i zapisujesz go na powrót.

BTW brakuje mi w PHP-owym DOM właśnie tego Selectors API, eh.
Go to the top of the page
+Quote Post
redeemer
post
Post #3





Grupa: Zarejestrowani
Postów: 915
Pomógł: 210
Dołączył: 8.09.2009
Skąd: Tomaszów Lubelski/Wrocław

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


Cytat(Comandeer @ 17.09.2015, 12:38:40 ) *
...
BTW brakuje mi w PHP-owym DOM właśnie tego Selectors API, eh.

https://github.com/electrolinux/phpquery



Ten post edytował redeemer 17.09.2015, 11:58:23
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: 17.10.2025 - 18:01