Question: The past 3 days I've tried to get this simple example to work but whatever I try I just can't seem to understand where I'm going wrong...

HTML:

```
<input type="text" id="textEntry" /> <button>Go</button>
<ul id="list">
    <li>Text from the input field will appear below</li>
</ul>

```

jQUERY:

```
$('button').click(function() {
    $enteredText = $('#textEntry').val();

    if($enteredText.length === 0) {
        alert('PLace an item in the field box');
    } else {        
        $newListItem = $('<li/>').html($enteredText).appendTo('#list');
    }

});

$('li').live('mouseover mouseout', function(event) {
    if(event.type == mouseover) {
        $(this).css('background-color', 'yellow');
    } else {
        $(this).css('backgorund-color', 'transparent'); }
});

```

Ultimately what I'm looking to do is have a user input an item into the text field which would then append itself to the existing list (this works - no issues). The user can then hover over a specific entry causing the background to turn yellow on mouseover and transparent on mouseout (the issue).

Any help would be swell. 

Thanks.

Answer: 
You can automate wildplasser's solution so that all sequences are synchronized with the current maximum value of their associated column:

```
do
$block$
declare 
  r        record;
  stmt     text;
  max_id   integer;
begin
  for r in (
              select *
              from (
                select table_schema, 
                       table_name, 
                       column_name, 
                       pg_get_serial_sequence(table_schema||'.'||table_name, column_name) as col_sequence
                from information_schema.columns
                where table_schema not in ('pg_catalog', 'information_schema')
              ) t
              where col_sequence is not null
        ) 
  loop
    stmt := 'select coalesce(max('||r.column_name||'), 0) + 1 from '||r.table_schema||'.'||r.table_name;
    execute stmt into max_id;
    raise notice 'Next ID for %.%.% is %', r.table_schema, r.table_name, r.column_name, max_id;
    perform setval(r.col_sequence, max_id); 
  end loop;
end;
$block$

```

Note that this will only work if the columns have been defined as `serial`, `bigserial` or have been made the "owner" of a sequence.
Another way is remove the primary key (id) from the columns (or don't dump the id). So your data would look like 

```
INSERT INTO book (name, price) VALUES ('Alchemist' , 10);

```

instead of 

```
INSERT INTO book (id, name, price) VALUES (1 , 'Alchemist' , 10);

```

This way, you won't have to reset the primary key after loading initial data