count objects in javascript - javascript

I have a little js problem and thought this wonderfull community would be able to help me!
Let's say I want to find all $('footer') elements and I want to know if there is either 1 or 2 footers on the page.
How would I do that?
using length() or something similar?
Thanks a lot for your help :)

Use the length[docs] property.
$('footer').length;
Please see the jQuery docs.
They're really very good, and typing length into the search field would dynamically bring the solution to you.

Or use the .size() function - see jquery docs
$('footer').size();

You can of course just use:
document.getElementsByTagName('footer').length;
But footer is an HTML5 element, many browsers in use do not support it yet.

Related

To change group image(what's the _calcBounds() do?)

When we want to change the src,we can use setElement().
The Example such like
`https://jsbin.com/lowuqezofu/1/edit?html,js,output`
It changes when we click the button at the bottom.
But when I add the image to the group like
`https://jsbin.com/xerureviwe/edit?html,js,output`
I want to use _CalcBounds() to update the group,but it runs error.
So I find the other document to solve it.
Here is the people who have related questions on it.
Because I haven't see this function on official tutorial of website.
I think I may not make some mistake.
If we don't need addWithUpdate() or removeWithUpdate() just set image src,is this method can do update function we want?
If not,is there any alternative to do this way?
Thanks for others view the question.
However,I haven't find the suitable solution yet.
I use addWithUpdate() and removeWithUpdate() stupidly instead of using _calcbounds() which function I don't really understand.
It's not a good answer indeed.
But non-perfect solution can solve our problem,that's enough.
Thanks everyone again and please forgive my poor English.

Ajax Based Multiple Auto Complete/ Auto Suggest Plugin

I am trying to find some plugin like the one, used in this website search box auto suggest.
http://www.propertyfinder.ae/en/buy.html
The second auto suggest list is based on the first keyword selected. I already know that mootools are used for it. If somebody knows about any plugin like this, please any advise.
Your suggestions will be a great help
Thank you!
Jus follow the link http://aehlke.github.com/tag-it/ you will get what you want
if you want to do this for mootools, then try this: http://mootools.net/forge/p/mootagify
demo that works with backspace bound:
http://fragged.org/mooTagify/Demo/
autocompleter for tags is built in. source code and also unit tests (via busterjs + syn) on my github page - https://github.com/DimitarChristoff/mooTagify/

coder textarea in javascript/jquery

I need a textarea that looks more like an programing environment, like notepad++. Basically, all I want is to insert TABs and keeps the cursor in the same indenting level as the previous line.
Any help on building my own would be greatly apreciated as well (my javascript/jquery skills are very basic).
thanks (:
Code Mirror would be a great option, it's easy to use with your skills.
You can also check this Wikipedia post for more information. http://en.wikipedia.org/wiki/Comparison_of_JavaScript-based_source_code_editors
Good luck ;)
Take a look at this link which will help you decide which editor to use based on your requirement. It has provided wide variety of JavaScript based editors with support for various browsers.
http://en.wikipedia.org/wiki/Comparison_of_JavaScript-based_source_code_editors
You can try this plugin for TABs http://teddevito.com/demos/textarea.html

javascript - document.form.textbox.style....can't seem to find this?

Can anyone help point me in the right direction - I have the following in a function:
document.form1.textbox1.style.display = 'none';
which works fine.
But I'm trying to find a list of all the possible 'elements'(?) that could come after style, e.g. '.display=', '.length=' etc, but I don't know the proper name/terms so the searches i'm doing are not returning what I want.
Any ideas? Thanks in advance! :)
leddy
See the CSS spec. Convert hyphenated-names to camelCase (e.g. backgroundColor not background-color).
Also see the DOM spec.
That said, in most cases it is usually better to modify the element.className (and have a pre–written, external style sheet) instead of modifying the element.style.*
Are you looking for this?
It also shows browser compatibility.
Style basically maps onto the CSS. As such, display is a CSS property - this is what your setting.
Take a look at CSS and you should understand what you can and cannot set.
Hope this helps!
Ben

Implementing a simple feedback form in JS

How do I implement the feedback form that the following sites have?:
http://foodoro.com/
http://www.heyzap.com/
(look at the left center.)
Thanks!
You should probably checkout the JQuery or similar library for this sort of effect. There are heaps of great tutorials and plug-ins out there.
I would use this code in github
https://github.com/lorenzoongithub/getsomefeedback
as a template / boilerplate.
It should be quite easy to adapt to your requirements.
Start by looking into jQuery. It's pretty nice for stuff like this.
http://www.webdesignerwall.com/tutorials/jquery-tutorials-for-designers/
The first example on there shows a simple way to at least get a sliding panel. It's not exactly what you want but it gives you an idea of what jQuery can do and maybe how you'd achieve what you want.
Edit: Here's a direct link to the sliding panel demo on there...
http://www.webdesignerwall.com/demo/jquery/simple-slide-panel.html

Categories