[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Поиск по странице
Markus111
Здравствуйте, подскажите как мне сделать вывод alert id блоков где встречается текст например 19

<input type="text" id="text-to-find" value="">
<a href="#"onclick="javascript: return false;">SEARCH</a>

<hr/>

<div id="p1">Монитор 19 дюймов</div>
<div id="p2">монитор 18 дюймов</div>
<div id="p3">Монитор 20 дюймов</div>

_____________
Womans in your town
tomash

for (var key in divs){
var div = divs[key];
if(div.innerHtml.test('19')){
alert(div.id);
}
}



_____________
Чтобы понять, что такое рекурсия - нужно понять, что такое рекурсия.
Markus111
Я добавил строки, а что должно быть в key
 <script type="text/javascript">
function div(text){
for (var key in divs){
var div = divs[key];
if(div.innerHtml.test(document.getElementById(text).value)){
alert(div.id);
}
}
}

</script>

<input type="text" id="text-to-find" value=""> 
<input
type="button" onclick="javascript: FindOnPage('text-to-find'); return false;" value="Искать"/>
<a
href="#"onclick="javascript:div('text-to-find'); return false;">SEARCH</a>

<hr/>

<div
id="p1">Монитор 19 дюймов</div>
<div
id="p2">монитор 18 дюймов</div>
<div
id="p3">Монитор 20 дюймов</div>


_____________
Womans in your town
Hello
http://jsfiddle.net/Lt4Ps/1/

_____________
VPS от 5$, первые 2 месяца - бесплатно.
Игорь_Vasinsky
впечатляет.

_____________
HTML, CSS (Bootstrap), JS(JQuery, ExtJS), PHP, MySQL, MSSql, Posgres, (TSql, BI OLAP, MDX), Mongo, Git, SVN, CodeIgnater, Symfony, Yii 2, JiRA, Redmine, Bitbucket, Composer, Rabbit MQ, Amazon (SQS, S3, Transcribe), Docker
Markus111
Hello ты очень помог, подскажите как узнать id="divPage750" c
function test() {
var list = document.getElementsByTagName('div'),
text = document.getElementById('text-to-find').value;
for (var i = 0; i < list.length; i++) {
if (list[i].innerHTML.indexOf(text) >= 0) {
alert(list[i].innerHTML);
}
}
return true;
}

<input type="text" id="text-to-find" value="">
<a
href="#" onclick="test();return false;">SEARCH</a>

<hr/>
<div
id="divPage750" title="Locked" class="dynDiv_setLimit" style=" position: absolute; border: 0px solid rgb(170, 170, 170); left: 156px; top: 235px; z-index: 198;"><div id="divPGstage750" title="Living Spaces" onclick="select_stage(750);" style="width: 100%; height: 100%"></div>
<strong><span
style="color:#585981;"><img alt="" src="./index_files/boxes.jpg" style="width: 300px; height: 271px; float: right; margin-left: 5px; margin-right: 5px; "><font color="#585981"><b>In Your Home: Living Spaces</b></font><br>
<br>

The most important place we want to feel at peace is at home. Drawers stuffed to overflowing, closets whose contents rain down on you when you open them and garages you can't park your car in not only cause us stress, but cost us money too. Let a certified home organizer help you create a system that works for you. From the junk drawer in the kitchen to the pantry, closets, and home offices, to garages and basements, no job is too small or too big for A Call to Order Professional Organizing Services.<br>
<br>

Many of us know that we need to get our clutter under control, but we don't know how. We wander through the Container Store, marvel at the abundance of systems that there are, and have no idea how to actually put them to use. At A Call to Order, we don't try to make you fit into a predetermined system; we work with you to find a solution that fits you.<br>
<br>

Having to search for things we need, not knowing what we have, wastes time and money. Does this scenario sound familiar? You need to wrap a present, but can't find any wrapping paper so you buy some, only to open the hall closet and have a roll of it fall on your head. A Call to Order Professional Organizing will help you create a way to know where things are.<br>
<br>
<font
color="#0000FF">Closets</font><br>
<br>

Closets are usually the first areas of our homes that become cluttered. We want to put things away, but the space inside the closet isn't configured correctly, so we just open the door and shove things in. It doesn't take long before we can't get another thing in the closet, and we can't find anything in it either.<br>
<br>

Different closets have different purposes, and need to be organized differently. A hall closet that needs to be able to hang coats in and store sports equipment will be set up differently than a hall closet that only needs to store winter coats and boots. A master closet that two people share has different needs than a master closet that only one person uses. A Call to Order can help you figure out what you need.<br>
<br>
<font
color="#0000FF">Kitchen</font><br>
<br>

Whether you are a gourmet cook or can barely boil water, a well-organized kitchen makes daily life easier. We all have to eat, and when we can find the proper tools and utensils, cooking at home becomes more manageable. A Call to Order can organize your pantry, help you sort through pots, pans and dishes to identify what you really need, and organize the junk drawer. We can identify your ideal workflow, and organize the cupboards so that their placement makes sense.<br>
<br>
<font
color="#0000FF">Home Offic</font>e<br>
<br>

Every home needs a home office space, whether it's a separate room, or a corner of the kitchen. A space where you keep and pay bills, have your computer and printer, and keep files needed for taxes. How you organize this space will have a huge impact on how productive you can be.<br>
<br>

From figuring out what kind of filing system works for you, to identifying what supplies you actually need, A Call to Order will find what really works for you.<br>
<br>
<font
color="#0000FF">Basements</font><br>
<br>

No other area of our homes is more prone to becoming a dumping ground than the basement. Out grown clothes, discarded toys, holiday decorations and unused furniture accumulate in piles or are haphazardly shoved in any available space. It's where we tend to put all those mementos that we think we must keep, but don't really know what to do with. A Call to Order helps you sort through the must keeps, want to keeps, and don't know why you are keeping items and make decisions on them. Then we help devise a system for keeping track of what you have, and knowing where it is.<br>
<br>

<div
id="p2">монитор 18 дюймов</div>
<div
id="p3">Монитор 20 дюймов</div>


_____________
Womans in your town
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.