开发者

Previous active control in javascript

开发者 https://www.devze.com 2022-12-30 18:00 出处:网络
I wanted to know how I could find the previous active control on a page. I have a couple of textboxes and a button, and when i am on a certain textbox and I click the button, I want to highlight that

I wanted to know how I could find the previous active control on a page. I have a couple of textboxes and a button, and when i am on a certain textbox and I click the button, I want to highlight that textbox. I have the highlight functionality covered, but I don't know how to find out which textbox to run the func开发者_JAVA技巧tion on...

Please help,

Thanks!


you'll have to keep track of it yourself you could try something like this:

var prev_el_id;

function focus_recorder(el)
{
    prev_el_id = el.id;
}

then on each element you want to track:

<input id='tb1' type='text' onfocus='focus_recorder(this)' ></input>

Then when you want to highlight the previous element you could just use the prev_el_id variable to find out which element it was.

0

精彩评论

暂无评论...
验证码 换一张
取 消