2
<a href="javascript:void(0);" class="selectedpagination"  onclick="changeuploader();">
    Try flash Uploader
</a>

If I write in anchor tag's first parameter javascript:void(0);, it will open link to controller/javascript:void(0)

Also, how do I give it the class name and onclick event?

3
  • use # inside href,, or try to remove that Commented Mar 12, 2012 at 13:19
  • @TechCare99 reworded things a bit, hope it still makes sense! If not, revert! Commented Mar 12, 2012 at 13:19
  • It looks like that codeigniter changes your output. The href looks good in my eyes. What's it changed into? Commented Mar 12, 2012 at 13:31

5 Answers 5

8

Easy as that:

anchor('#', 'Try flash Uploader', array('class'=>'selectedpagination', 'onclick'=>'changeuploader();'));

Check this https://www.codeigniter.com/user_guide/helpers/url_helper.html

Sign up to request clarification or add additional context in comments.

7 Comments

what about javascript:void(0) doesn't it need ?
use # instead...I've tested and I see that even with it...it will reload the page....I'l make some more tests and report back
# will make the browser move the view-port eventually.
yeah..it will...to avoid reloading the page, you can add a return false to your onclick event after your JS function. Maybe it won't work because your JS is returning something, I don't know. About move the view-port, I don't think it will be possible to solve with anchor(), if possible, you can create the link manually and it will work the way you need
@Gerep ... Nope. Still using core PHP Code Only.
|
1

Please stop doing <a href="javascript:void(0);" ... >. It is an extremely bad practice. And so is attaching events in HTML.

Instead you should attach events in an external JS file. PHP framework has nothing to do with this.

4 Comments

you are right but the thing is that he need to use the framework to create the link and the function for that need a href and TechCare needs it to ignore the click
@tereško may be u r right , but surfing through stackoverflow, I came through this : [link]stackoverflow.com/questions/134845/… person is having 233 Ups for his answer. ::: More Confused :::
@TechCare99 , did you check to see which answer had bounty awarded ? stackoverflow.com/questions/134845/…
@tereško ... Yes saw that too, thats why I am more confused :| _italic_( I am just a new to JS + jQuery !!! )
0
  1. onclick="return false();"

    $('.selectedpagination').click(function(){ //To click here });
  2. You can use button.

Comments

0

I didn't find another solution instead of: $("a").removeAttr("href");

Comments

-1

Try this

<a href="javascript:void(0);" class="selectedpagination"  onclick="javascript:changeuploader();">
    Try flash Uploader
</a>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.