TechCare99
TechCare99

Reputation: 1831

How to create javascript links in CodeIgniter

<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?

Upvotes: 2

Views: 5173

Answers (5)

user745235
user745235

Reputation:

Easy as that:

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

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

Upvotes: 8

Felipe Campanhol
Felipe Campanhol

Reputation: 79

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

Upvotes: 0

Ferhat KO&#199;ER
Ferhat KO&#199;ER

Reputation: 4075

  1. onclick="return false();"

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

Upvotes: 0

rash111
rash111

Reputation: 1317

Try this

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

Upvotes: -1

tereško
tereško

Reputation: 58444

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.

Upvotes: 1

Related Questions