开发者

remove text from a function (i think)

I am trying to remove the "_" in the "change_option". I managed to add the class ok bu开发者_JAVA技巧t that's it

<select onchange="change_option('SELECT___100E___7',this.options[this.selectedIndex].value)" name="SELECT___100E___7" class="link_fix3">

Here is the code I have so far...

$("form select[onchange^='change_option']")
    .addClass('link_fix3')
    .attr('onchange', function(k,x){
     return x.replace('_','');})


Without knowing the internals, it seems you're trying to call changeoption(name, value), you can do this entirely in jQuery, like this:

$("form select[onchange^='change_option']")
  .addClass('link_fix3')
  .change(function() {
    changeoption(this.name, $(this).val());
  });

Though with more details, this can probably be even simpler, for example is giving the <select> a class initially an option? That would make the selector much cleaner, then you can leave the initial onchange attribute off completely...you have to admit this looks prettier :)

<select name="SELECT___100E___7" class="link_fix3">

Script like this:

$("form select.link_fix3").change(function() {
  changeoption(this.name, $(this).val());
});

If you post what your changeoption function looks like, I could improve the answer to show additional simplifications, if any of these options I'm offering are do-able...I know the programmers control over markup varies widely, so let us know what options you do have.


just a thought... if you do this,

$("form select[onchange^='change_option']")
    .addClass('link_fix3')
    .attr('onchange', function(k,x){
     return x.replace('_','');})

the output would be,

onchange="changeoption('SELECT00E7',this.options[this.selectedIndex].value)" // notice your, 'SELECT___100E___7'

I suggest this,

$("form select[onchange^='change_option']")
        .addClass('link_fix3')
        .attr('onchange', function(k,x){
         return x.replace('change_option','changeoption');})

that is, if you really want to solve it that way...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜