🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.javascript
4 messages
4 total messages Started by hazet Fri, 08 Apr 2011 08:36
[jquery] Jak zrobić focus
#50702
Author: hazet
Date: Fri, 08 Apr 2011 08:36
29 lines
1714 bytes
Zmodyfikowałem pewien skrypt w jquery,
chodzi o to, że klikając w jeden element (input), w innym dodawana jest 
klasa.
Problem w tym, że po kliknięciu w drugi element (input), w którym ma być 
hasło, wartość w tym pierwszym jest czyszczona.

W każdym razie, to jest skrypt:

$(document).ready(function() {
	$("#login input").focus(function() {
		$("#login").addClass("active");
         if (this.value == this.defaultValue){
         	this.value = '';
     	}
         if(this.value != this.defaultValue){
	    	this.select();
         }
     });
     $("#login input").blur(function() {
     	$("#login").removeClass("active");
         if ($.trim(this.value == '')){
         	this.value = (this.defaultValue ? this.defaultValue : '');
			
     	}
     });
});

Jak zrobić aby value #login input nie było czyszczone po przejściu do 
#pass input ?
Re: [jquery] Jak zrobić focus
#50703
Author: Paweł Piskorz
Date: Sat, 09 Apr 2011 15:46
10 lines
1101 bytes
On 2011-04-08 10:36, hazet wrote:
> if ($.trim(this.value == '')){

Hmmm, po co trimmujesz wynik porównania?


-- 
message[autor="PablO"]::after {
	content:"Pozdrawiam";
}
Re: [jquery] Jak zrobić focus
#50704
Author: hazet
Date: Sun, 10 Apr 2011 09:07
11 lines
1233 bytes
Paweł Piskorz pisze:
> On 2011-04-08 10:36, hazet wrote:
>> if ($.trim(this.value == '')){
> 
> Hmmm, po co trimmujesz wynik porównania?
> 
> 

nie wiem, pobrałem to z sieci.
Pierwotnie skrypt był przeznaczony dla pola wyszukiwania A ja potrzebuje 
go dla login i pass.
Re: [jquery] Jak zrobić focus
#50705
Author: Paweł Piskorz
Date: Sun, 10 Apr 2011 16:39
22 lines
1490 bytes
On 2011-04-10 11:07, hazet wrote:
> Paweł Piskorz pisze:
>> On 2011-04-08 10:36, hazet wrote:
>>> if ($.trim(this.value == '')){
>>
>> Hmmm, po co trimmujesz wynik porównania?
>
> nie wiem,

A rozumiesz w ogóle co jest w tej linijce i dlaczego jest bez sensu?

> pobrałem to z sieci.

Albo Ci CTRL+C/CTRL+V nawala, albo nie sprawdziłeś skryptu który 
skopiowałeś - powinno być tak:
if ($.trim(this.value) == ''){


-- 
message[autor="PablO"]::after {
	content:"Pozdrawiam";
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads